You are not logged in.

1

Wednesday, January 1st 2014, 9:12pm

Image Change on Toggle Button Help

Hi - does anyone know how to change the image on a toggle button when clicked On/Off??

I am not using a sprite and would like to just reference a .png file for each. Here is the code I have now on the vtourskin.xml...

Image Reference is ok -


<!-- skin_base - the base skin image -->
<style name="skin_base" url="vtourskin.png" />
<style name="play" url="icon_play.png" />
<style name="pause" url="icon_pause.png" />


Need help adding image references here...



<layer name="skin_btn_rotate_play" style="play|skin_glow" align="leftbottom" x="185" y="4" scale="0.5" zorder="2" alpha="1.0" onhover="showtext('Play / Pause', SKIN_TOOLTIPS);" ondown2="if(autorotate.enabled == true, set(autorotate.enabled,false);, set(autorotate.enabled,true));" />

2

Thursday, January 2nd 2014, 10:43am

Hi,

I would recommend using several elements and showing and hiding them - when changing the url, the image need to be reloaded and this can take a bit of course.

Regarding changing the url itself - just set the url to new one,
e.g. when directly calling from an event of an element, you can change the attributes directly:

Source code

1
set(url, 'newimage.png');


when not directly calling the the full attribute path need to be used:

Source code

1
set(layer[skin_btn_rotate_play].url, 'newimage.png');



In your case with the <style> usage, you could also use the loadstyle() action to load the attributes from the given style,
e.g.

Source code

1
loadstyle(play);

or

Source code

1
layer[skin_btn_rotate_play].loadstyle(play);


Best regards,
Klaus