Flash Button 101

I was at an education seminar this week and promised the attendees to post the 3 lines of Actionscript code for use with buttons (and indeed for everything else in Flash). Learn the 3 lines of codes and you have everything you need to code in Flash as all objects (visual as well as non-visual) follow the same event driven (event and response) model. So here it is, put the following code on the timeline layer and assuming the button on the stage has an instance name “myButton_btn”:

myButton_btn.addEventListener(MouseEvent.CLICK, doClick);
function doClick(e:MouseEvent):void
trace (“Hello World!”);


~ by brianchau on November 26, 2009.

2 Responses to “Flash Button 101”

  1. I’m a professional Actionscript developer and Ive been looking for this code for ages. Thanks.

  2. Hello Brian, doubt you’d remember me but a few years back you helped me make abutton that played different scenes. Years later now I am making a flash site for friday class am stuck when im trying to make a game, if you have the free time and could help I made a thread here.


    It includes my website and the full story ty either way and

    awesome site dude

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: