Creating a Simple Button in Flash
In the early days of Flash authoring, creating a button usually involved creating a multiframe movie clip symbol and drawing a design in each frame to change the button's appearance for different mouse states. Now, the "Components" feature makes it easy to add buttons and other user interface elements to your Flash application. Drag a button from the Components panel to the Stage to create a button, and add an event handler to your Actionscript code to make it do something.
- Difficulty:
- Moderately Easy
Instructions
-
-
1
Click the "Window" menu and choose "Components" to reveal the Components panel.
-
2
Drag the "Button" entry in the "User Interface" category to the Stage. You can also double-click it. Your button is created.
-
3
Click the "Window" menu and choose "Component Inspector" to reveal the Component Inspector. Click the "Parameters" tab if it isn't already selected. As long as the button you created is selected, its basic properties can be specified in this tab.
-
4
Click the entry in the "Value" column to the right of the "label" parameter, and type a label for your button.
-
5
Click the "Window" menu and choose "Properties" to reveal the Property Inspector.
-
6
Input an instance name for the button in the text field at the top of the Property Inspector. This name is used to identify this particular button in Actionscript code.
-
7
Add the following line to your Actionscript code to call a function called "buttonClicked" when the button is clicked:
INSTANCENAME.addEventListener(MouseEvent.CLICK, buttonClicked);
Replace "INSTANCENAME" with the name you chose in Step 6. Your button is now functional.
-
1