advertisement

Well in this tutorial I will be teaching you how to make buttons in flash.

First step, open flash, any dimensions and any frame rate. Now we want to make the movie stop on the frame that you have your button in, so select the frame that you want your button in on the timeline and open up the actions panel (F9) and add this code:
[as]
stop();
[/as]

Ok, so now that the movie stops, we need our button. So select the rectangle tool at the side
rectangle tool
and draw a rectangle on the stage, then select the text tool and write some text over the rectangle relevent to what you want your button to do, for my example I will write play over mine.

Next select the rectangle and the text over it and go to Modify > Convert to symbol… or press F8 it will come up with a box like the following…
Convert to symbol box
now change the fields so it looks something like the following…
Convert to button
1 – Name: It doesn’t really matter but if you go back to a file it helps you know what everything is.
2 – Type: Important, for a button you want it to have a type of button.
3 – Registration: Doesn’t really matter for buttons.

Ok, so we have our button but it doesn’t do anything yet. On the UI there is a little panel at the bottom called “properties”, I want you to open it. Now with your button selected, change the instance name to button, like the picture below:
instance name
1 – Instance name: Change this to button.

Now the code to make the button work. Usually I would make you put this in the button but because of AS3 coming out I am going to do it like this:
[as]
button.onRelease = function() {
gotoAndPlay(x);
};
[/as]
This means that when the object with the instance name of button is pressed it calls a function which takes you to the frame specified in the () tags. The example above will give you a sytax error, this is because you need to change the x to the number equal to the frame that you want the button to take you to; If I wanted the button to take me to frame four, I would change the code to:
[as]
button.onRelease = function() {
gotoAndPlay(4);
};
[/as]

Buttons in flash can do other things aswell, for example if you wanted a button to link back to a website, you would use this code:
[as]
button.onRelease = function() {
getURL(“http://www.tutorialcode.com”);
};
[/as]
or if you wanted a button you email to a certain email address:
[as]
button.onRelease = function() {
getURL(“mailto:example@website.com”);
};
[/as]

So the basic code for the frame is:
[as]
stop();

button.onRelease = function() {
gotoAndPlay(2);
};
[/as]
(that will take you to frame 2).

Thankyou for reading,
mortisimus

P.S. If you have any problems or anything, just comment.

http://www.flashdoom.net/

advertisement