ANIMATED BUTTONS as3 |
From the actionscript point of view very simple tutorial. From the actual animation side, well thats up to you how complex
animation you want to have on your buttons. I will not teach you how to create awsome animations , but I will show you the actionscript behind it that is same regardles how complicated the
animation is. Down below are two basic examples of animated buttons.
The entire idea is based on mouse events MOUSE_OVER and MOUSE_OUT. So for now create lets say rectandle. Covnert it to movieclip and set its instance name to
RMbtn.Open this movieclip and on 1st and 10th frame enter stop(); script. The roll over animation will run between frames 2 and 10 , and the roll out animation
will run between frames 10 and 20. Ofcourse length and number of animations is zour decision, just make sure you change the frames numbers in actionscript. Now exit movieclip to stage. Select frame and
enter the following actionscript code:
RMbtn.addEventListener(MouseEvent.CLICK, RMbtnclick); RMbtn.addEventListener(MouseEvent.MOUSE_OVER, OVERbtn); RMbtn.addEventListener(MouseEvent.MOUSE_OUT, OUTbtn); RMbtn.buttonMode = true; function RMbtnclick(ev:MouseEvent):void { trace("INFO has been clicked."); } function OVERbtn(ev:MouseEvent):void { RMbtn.gotoAndPlay(2); } function OUTbtn(ev:MouseEvent):void { RMbtn.gotoAndPlay(11); }
Line 3 is definition of Password function. First three lines adds event listeners to mouse click, roll ouver and roll out to the button. Each
of them will execute different function which will start the animations itself. Line 4 adds hand course for buttons, since movieclips does not have them by default. If you dont like
it, simply delete this line. Function RMbtnclick will run after the button is clicked, function OVERbtn when mouse enters movieclip and OUTbtn when mouse cursor leaves movieclip.
|