Forum Discussion

BarbaraJacobs-1's avatar
BarbaraJacobs-1
Community Member
6 days ago

JavaScript to change image

Any JavaScript for changing a background image within a slide master in Storyline 360? Yes, I could add another slide master, but that's not as much fun! 😁

4 Replies

  • It would be the identical .state notation as a non-master slide, wouldn't it? What's different for you about when the slide is a slide master? 

    • BarbaraJacobs-1's avatar
      BarbaraJacobs-1
      Community Member

      Happy Friday! 🤔

      Fewer slides to maintain, means fewer potential errors, smaller file size, less work, especially if applied in multiple instances.  

      • AndrewBlemings-'s avatar
        AndrewBlemings-
        Community Member

        I'm definitely with you on the benefits of slide masters, and I have a lot of success putting code on one master so as to invoke it on subordinate instances. I guess that's why I'm wondering if there's another factor I'm not considering.

        To test, I imported a stock image and gave it a second (non-Normal) state that reversed the image.

        Then on the start of a slide master, I added a JavaScript trigger that captures the image object:

        const img = object(id);

        And then if the mouse is on the on the left half of the slide, show the flipped state of the image. If the mouse is on the right half of the slide, show the normal state of the image:

        if (pointerX() < slideWidth()/2) {
            img.state = 'Flipped';
        } else {
            img.state = 'Normal';
        }

        This kind of code works identically on slide masters as well as lower-level instances, which is why I suspected maybe there's some other aspect of changing an image on a slide you're encountering.