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));" />

  • 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:

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

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

    Code
    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.

    Code
    loadstyle(play);


    or

    Code
    layer[skin_btn_rotate_play].loadstyle(play);

    Best regards,
    Klaus

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!