Buttons
| Category | : Flash | Views | : 10237 | ||
| Version | : 8 | Rating | : | ||
| Type | : Text | Source File | : buttons.zip | ||
| Result | : See the result | ||||
Buttons simple to use, create and one of the most useful things in Flash. Let’s start by creating a button.
Right click inside the library tab and select "New Symbol..."

Don’t forget to check "Button" and to give it a name.
I may have noticed that the timeline is different from the usual. This one only has four frames: "Up", "Over", "Down" and "Hit". They represent the states of the button.

On the "Up" frame you draw how you want your button to look like when it’s not being clicked and doesn’t have the mouse over it.
If you want to make more complex buttons you can add more layer to the timeline just line for a Movie Clip. In fact, you can also add a Movie Clip inside your Button! Try later to animate a Movie Clip and drag it to one of your button’s frame.

The "Over" frame is how you button looks when the mouse is over it, but not clicking.

"Down" frame is your button when the mouse is being pressed over it.

And "Hit" is the area where the mouse events occur.
So if you draw a smaller button on this frame, the over and down event will only happen if the mouse is in that small area. For our tutorial leave this frame empty.
Now let’s move to the actionscript part.
The main events for buttons are:
//When the mouse is pressed over the button.
onPress = function()
{
}
//Mouse was pressed in the button then released.
onRelease = function()
{
}
//Mouse pressed over the button then released outside the button.
onReleaseOutside = function()
{
}
//Mouse rolls over the button.
onRollOver = function()
{
}
//Mouse rolls out.
onRollOut = function()
{
}
Just add your code between the curly braces and test it.That’s all for this tutorial.
![]() |
![]() |
![]() |
![]() |
![]() |




