Flash tutorials
Home 3D (2) Actionscripting (66) Animation (108) Audio (4) Drawing (7) Full flash sites (4) Getting Started (15) Navigation (25) Special Effects (61) Text Effects (38)

Interactive icon button using the AS

23.6.2009, 18:4    Total views: 23695

We are going to learn how to create interactive icon button using the action script code and some special flash tips and tricks. You can use this button for some web site, or for some flash menu. Using this lesson, you will also learn how to import any icon into a flash stage, how to convert it into a Movie Clip Symbol, how to create instance name, invisible button and much much more!

Example:



Step 1

First, find any icon which you like to use for this lesson. You can also, if you like, save my icon below.





Step 2


Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set the dimensions of your document as whatever you like. Select any color as background color. Set your Flash movie's frame rate to 32 and click ok.

Step 3

Call the current layer icon. Double-click on its default name (Layer 1) to change it. Press Enter once you have typed in the new name!

Step 4

Choose now File > Import > Import to stage (Ctrl+R) and import any icon into a flash stage.

Step 5

While the icon is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.



Step 6

While the new made Movie Clip is still selected, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip icon. See the picture below!



Step 7

Double-click on the movie clip on stage with the Selection tool(V).You should now be inside the Movie Clip.



Step 8

While the icon is still selected, hit again F8 key (Convert to Symbol) to convert it again into a Movie Clip Symbol.



Step 9

Click now on frame 10 and hit F6 key. While you're still on frame 10, move your icon a little left.

Step 10

After that, select the Selection Tool (V) and click once on the icon to select it. After that, go to the Properties Panel (Ctrl+F3) below the stage! Then, select Filters tab from the left side. Click after that on the plus icon and select the Bevel filter. Make the adjustments as follows:



Step 11

Right-click anywhere on the gray area between the two keyframes on the timeline and choose Create Motion Tween from the menu that appear.

Step 12

Go back on the main scene (Scene 1).

Step 13

Create a new layer above the layer icon and name it Invisible Button.

Step 14

Select now the invisible button layer and take the Rectangle Tool (R). In the Colors portion of the Tool panel, block the Stroke color by clicking on the little pencil icon and then on the small square with the red diagonal line. For Fill color choose any color and draw the Invisible Button over the icon. See the picture below!



Step 15

Select now the Selection Tool (V), click once on the Invisible Button to select it, open the Action Script Panel (F9) and enter the following Action Script code, inside the Actions panel:

on (rollOver) {
_root.mouse_over_icon = true;
}

on (rollOut) {
_root.mouse_over_icon = fstartlse;
}

on (release){
getURL("http://www.flashvault.net/");
}

Step 16

Create a new layer above the Invisible Button layer and name it action. Then, click on the first frame of layer action and enter the following Action Script code inside the Actions panel:

_root.icon.onEnterFrame = function() {
if (mouse_over_icon) {
_root.icon.nextFrame();
} else {
_root.icon.prevFrame();
}
};

We're done now!

Test your movie and enjoy!

Download source file (.fla)

Have questions about this tutorial?
Visit our friendly Community Forums!
Digg it! Add this tutorial to del.icio.us! Furl it! Add this tutorial to reddit! Spurl it! Add this tutorial to technorati!

Top tutorials

1. Advanced full flash site - Part 1
Total views: 310287

2. High-tech city animation
Total views: 272904

3. Water effect
Total views: 237059

4. Photo slide show
Total views: 220388

5. Special Picture Effect
Total views: 190723



Related links