Forum Discussion
Changing state directly from JavaScript?
Just figured out how to trigger states from Javascript. First of all you have to realize that Storyline use SVG to create inline SVG images from any element you import. When inspecting the output you will notice that when you create a new state ( for hover or whatever ) SL actually creates a new image for that state. With some completely absurd names like '6mCzuc95iTc_80_RFFBC7C_DX820_DY820_CX410_CY318.png' ...based upon your original name..and then some...
with setAttribute('xlink:href',2ndStateImg);
you then can activate a state..in fact you are not activating a state but doing exactly the same Storyline does, you are replacing a source image.
I have this working in a sample. However as is, this is still hard to use, due to the way Storyline publishes images with those tough names. Im working on a setup that at start gets all names of the images in your Storyline and then its easy to work with.
Will share that when i got it working...