Action Script 3.0 [Real One] – Tutorial One – Clicked Button Only

Assalammualaikum,

Today I would like to share some of stuff that I’ve learned during Computer Games Development Training from October 3 until October 7 2011.

1.Create new .fla file which is Action Script 3.0 based file

2. Draw a rectangle in the layer and remove the rectangle line and then convert the rectangle into a symbol. Please make sure to rename it accordingly. And then you also to name the instance name for that symbol that you have created. Make sure to select Movie Clip and not a Button Type. Let say, symbol name is “buttonrec” and the instance name is “button_rec”. It is not the same, between symbol name and instance name. Instance name is for you to call using action script 3.0 and the symbol name is for you to use it for multiple instance name. Got it? Then Google it.

3. After that, make a new layer above it and then rename the layer. Press F9 and start the command below:

stop(); //to stop anything from running automatically

button_rec.ButtonMode = true; //to set it as a special button not the ordinary button

button_rec.addEventListener(MouseEvent, CLICK, funcplaysomestuff); //note that funcplaysomestuff is a function

function funcplaysomestuff(e:MouseEvent)

{

trace(“You’ve Clicked a Button”);  //this function similar to cout in C++ and printf in C language

}

Now you need to make sure to hit CTRL  + ENTER to play it. Once you run it, then you will know that at the output window will display You’ve Clicked a Button.

There you are. First Tutorial on Action Script 3.0

Published by razorjr

Research and Academician

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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: