Thursday, December 24, 2009

Hi 鈥? I am trying to find an actionscript for my website to alternate between two images when clicked.?

The main image is a lampshade and the second is the lampshade looking as though it has been turned on. I want people to be able to turn the lamp on and off whenever they click, but I am having trouble getting it to go back and forth. Any tips? Thank you!Hi 鈥? I am trying to find an actionscript for my website to alternate between two images when clicked.?
something like this


%26lt;html%26gt;


%26lt;body%26gt;


%26lt;img id=';i'; src=';jnd1.jpg';


onmouseover = 'document.getElementById(';i';).src = ';jnd2.jpg';'


onmouseout = 'document.getElementById(';i';).src = ';jnd1.jpg';'/%26gt;


%26lt;/body%26gt;


%26lt;/html%26gt;Hi 鈥? I am trying to find an actionscript for my website to alternate between two images when clicked.?
For Actionscript 2.0 you could approach this in several ways.





You could have a new symbol with 2 frames, frame 1 having the ';off lamp'; and a ';stop()'; line of code, the second frame with the ';on lamp';.





Then in your buttons etc. use:





For off to on:


on(release)


{


mcLamp.gotoAndStop(2);


}





For on to off replace 2 with 1





Alternatively, you could have each as a separate movie symbol and layer on top of each other, then on teh first frame of the root target the ';on'; clip,


mcLampOn._visible = false





then have a button that flips between them.





on(release)


{


mcLampOn._visible = true


mcLampOff._visible = false.


}





You could always play with _alpha (less recommended) or look up dynamically instantiating movieclips from the library, but this would explain more ancillary explanation.


}

No comments:

Post a Comment