Adding
Actions to Buttons
You can assign an action
to a button or a movie clip, make an action execute
when the user clicks a button or rolls the pointer over
it, or when the movie clip loads or reaches a certain
frame. You assign the action to an instance of the button
or movie clip; other instances of the symbol aren't
affected.
To display the Actions panel in normal mode:
1. Select Windows / Actions.
2. Do one of the following:
Click the arrow in the upper right corner of the Actions
panel to display the pop-up menu, and choose Normal
Mode.
Click anywhere in the Actions panel. Then press Control+Shift+N
(Windows) or Command+Shift+N (Macintosh).
To view a description of an action, do one of
the following:
Click a category in the Actions toolbox to display
the actions in that category, and click an action.
Select a line of code in the Script pane.
The description appears at the upper right of the Actions
panel.
To add an action to the Script pane, do one of the following:
Click a category in the Actions toolbox to display
the actions in that category. Then either double-click
an action, drag it to the Script pane, or right-click
(Windows) or Control-click (Macintosh) and select Add
to Script.
Click the Add (+) button and select an action from the
pop-up menu.
Press Escape and a shortcut key. For example, Escape+st
adds a stop action. (To view a list of shortcut keys,
select View Esc Shortcut Keys in the Actions panel pop-up
menu; select this option again to hide the list.)
To delete an action:
1 Select a statement in the Script pane.
2 Click the Delete (-) button or press the Delete key.
When
you assign an action to a button or a movie clip, Flash
automatically assigns a special action called a handlerthe
On Mouse Event action for buttons or the On Clip Event
action for movie clips. A handler manages an event in
a certain way and contains groups of ActionScript statements
that run when a specific event occurs. Each handler
begins with the word on or onClipEvent followed by the
event to which the handler responds.
Events are actions that occur while a
movie is playingfor example, a movie clip loading,
the playhead entering a frame, or the user pressing
a key on the keyboard. You can specify the mouse event
or keyboard key that triggers the action; see Setting
mouse event options. You can also specify the clip event
that triggers the action; see ActionScript Help.
Once you've assigned an action, it's recommended
that you test whether it works. Only simple frame actions
such as Go To and Play work in editing mode.
The following instructions describe how
to set actions for objects using the Actions panel in
Normal Mode.
To assign an action to a button or
movie clip:
- Select a button or movie clip instance
and choose WINDOW / ACTIONS.
If the selection is not a button instance, a movie
clip instance, or a frame, or if the selection includes
multiple objects, the Actions panel will be dimmed.
- In the Toolbox list on the left side
of the panel, click the Basic Actions category to
display the basic actions.
For a description of the actions you can add, see
Using basic actions for navigation and interaction.
- To assign an action, do one of the
following:
Double-click an action in the Basics Actions category.
Drag an action from the Basic Actions category on
the left to the Actions list on the right side of
the panel.
Click the Add (+) button and choose an action from
the pop-up menu.
Use the keyboard shortcut.
If you selected a movie clip, Flash automatically
inserts the On Clip Event action and the action you
selected in the Actions list. If you selected a button,
Flash automatically inserts the On Mouse Event code
to trigger any selected action.
- To display the Parameters pane, click
the triangle in the lower right corner of the Actions
panel. Select the action and enter new values in the
Parameters text boxes to change parameters of existing
actions.
Parameters vary depending on the action you choose.
For example, the default On Clip parameter is Load.
See Using basic actions for navigation and interaction
for information on parameters for the most commonly
used actions.
- Repeat steps 3 and 4 to assign
additional actions as necessary.
|