Forum Discussion
GSAP 3.5.1 ( latest version ) is now included in Storyline 360
Hi Math
I really appreciate the time you take to answer questions here - and you are clearly, the man to go to for advice on GSAP.
I'm new to GSAP but I like the potential it creates for developers in Storyline. I'm starting with small steps and it's looking good, I can move images, add effects etc.
A quick question though, if I may post it here? I'm assuming you can't change the 'src' property of an image in Storyline? I saw your post on dynamically loading a QR code - so I'm guessing if it had been possible to dynamically load an image from Storyline using GSAP by changing the src you would have gone that route?
This code works in straight JavaScript:
- MathNotermans-92 years agoCommunity Member
In fact you can change the src image of any 'real' image in Storyline on runtime. I do think i have samples showing that....
https://community.articulate.com/discussions/articulate-storyline/how-to-create-dynamic-texts-links-and-dynamic-images-in-storyline
The url above shows a bit of it. In the end i ended up generating the QR's dynamically as they needed added customizable querystrings.
In the end there are 2 solutions to creating / changing images with Javascript. One is using a WebObject to point to some URL ( i use Cloudinary, so you can also allow users to upload images and change them on the fly ). Then an action can change the url/src of the image/WebObject.
Another one is adding multiple images upfront to your resources and then you can switch them on an action. You need to setup a array for them... like this...var urlArray = [
'story_content/external_files/avatar1.png',
'story_content/external_files/avatar2.png',
'story_content/external_files/avatar3.png'
];
Then you can either add them to the viewport...or change the href of an existing image on screen by one from the array.Do share a sample and i will see if i can help better.
Do try GSAP to change the src... it will work.