Flash Button Tutorial
Difficulty: Beginner
Download fla Source
Here is what you will be creating:
Making a flash button is pretty simple. Below is the basic code you need to add to your code in order for your button to be clickable.
Step 1
Add a button to the first frame of your flash movie and convert it to a MovieClip symbol

Step 2
Name your button button_mc using the instance name box at the lower left

Step 3
Create a new layer called script.

Add the code provided below to the first frame on the script layer:
button_mc.onPress = function() { // When button is pressed, go to the provided link
getURL("http://www.premiumbeat.com");
} You can also open the link in a new browser window by using:
getURL("http://www.premiumbeat.com","_blank");
Great! You have created your first button in flash. But now you want to make it more dynamic and interactive. To achieve this, we will add a rollover effect to the flash button.
1. Open your button and add a second frame to the timeline
2. Modify the button appearance on the second frame

Frame 1
button is off

Frame 2 button is on
Code to add a rollover to a flash button:
button_mc.onRollOver = function() { this.gotoAndStop(2);
}
button_mc.onRollOut = function() { this.gotoAndStop(1);
}
What this code
does is basically:
- When a rollover occurs on button_mc, go to the second frame of this button
- When a rollout occurs on button_mc, go back to the first frame of this button
That's it! Send any questions or comments to info@premiumbeat.com |