Forum Discussion
Changing state directly from JavaScript?
First steps done. So in the course attached images on screen are hidden and shown by Javascript.
Main trick behind is is using the 'accessibility-names'. When you check the title you notice the image-buttons are named 'state hatch bad' etc, as you can see in this image.
For ease of use in coding Javascript i always rename the layer to its accessibility name. Thus making it easy to find and remember naming. The 'space' in the naming makes it easy to select all elements...by using a selector like this...$("[data-acc-text*='state']"
or a specific subselection of the elements... $("[data-acc-text*='state dark']"
or even a specific element $("[data-acc-text*='state dark good']"
The sample as added uses a Webwindow with specific Javascript libraries to ensure all works. I always use JQuery and GSAP Tweenmax. As is GSAP is not free, when you want to use GSAP animation on a course or site, you need a licence. Its totally worth it for sure.
This for sure not yet is a solution for how to script 'states' with images. Its only a first step. Next step will be replacing an images source. Then its quite a bit closer to the way Storyline handles its states...That will be next step i show.