How to create button events in adobe flash cs5 ?
Creation of button same as old Flash versions
Go Insert menu click on New Symbols ( Insert > New Symbols ) or Ctrl + F8 , Once you select New symbol u can view a dialogue box like bellow , Name are i am going to create button name as ”Mybutton” and type Button

Adobe Flash CS5 - New Symbol
Once you click it take to you on mybotton event handling area button Create a button, create a button shape and in time line , you can get facility to change the your designed button color or animation in different stages like up , down, over, hit . I made a small button you can view bellow .

Button
Back to Seen 1 , from window you will get Library you can view button on there ( Window > Library or Ctrl+ L) please insert mybutton to seen1 from my library. Now we are going to apply a action to mybutton
Under window menu please choose ” code snippets ” on left side can view window like bellow it contain some default codes can customise easily.
take action window or press f9 key to get action window click on button on from seen1 then and on button property window name as “mybutton”

mybutton
to apply action we need separate stage so please create a new layer name Action now we are going to write actions on Action:frame1 , select mybutton and click on “Click on go to webpage ” Actions folder
mybutton.addEventListener(MouseEvent.CLICK, samname);
function samname(event:MouseEvent):void{ navigateToURL(new URLRequest(“http://www.helplazysam.com”), “_blank”);}
you will get a above code now event applied for that button made change links under url request : run flash the button once you clicked button it goes to that link
mybutton.addEventListener(MouseEvent.CLICK, samname); ( function)
we are adding a events to our button like mybutton.adeventlistener ( events, function name )
Events like mouseevent.click or move drag etc .. and function name given as same name


Posted in 


