Page 1 of 1

Replacing image dynamically

PostPosted: Tue Jun 14, 2016 9:03 pm
by Ronnie
Hi
How do I replace image dynamically...
Below code doesn't work when I tried to change image [imgA] to [img1] which should show "c:\temp\d1.png"


SetVar [img1] "c:\temp\d1.png"
SetVar [img2] "c:\temp\d2.png"
SetVar [img3] "c:\temp\d3.png"
SetVar [img4] "c:\temp\d4.png"
SetVar [img5] "c:\temp\d5.png"

Button script:
SetVar [imgA] [img1]

Thanks

Re: Replacing image dynamically

PostPosted: Wed Jun 15, 2016 2:31 am
by luishp
Ronnie, for this to work you must assign [imgA] variable to Source image property on the properties panel.
On the other hand, browsers use normal slashses for URLs:

Code: Select all
SetVar [img1] "c:/temp/d1.png"
SetVar [img2] "c:/temp/d2.png"
SetVar [img3] "c:/temp/d3.png"
SetVar [img4] "c:/temp/d4.png"
SetVar [img5] "c:/temp/d5.png"

Button script:
SetVar [imgA] [img1]


Anyway, using absolute paths is not a good idea when dealing with webapps.

Re: Replacing image dynamically

PostPosted: Wed Jun 15, 2016 6:43 pm
by Ronnie
Thanks.
When compiled to web, the image don't show even when I added the images via Project > Properties > Libraries/Files.
I noticed the images are stored in 'img' folder in the compiled web..

To resolve, I stored all required images to a 'img' sub folder, added to Libraries/Files, and changed the script to:

SetVar [img1] "img/d1.png"

That works.