Understanding ActionScript > Assigning actions to objects
Assigning actions to objectsYou can assign an action to a button or a movie clip to 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 assign an action to a frame, see Assigning actions to frames.)
When you assign an action to a button, you must nest the action inside an on(mouse event)
handler and specify the mouse or keyboard events that trigger the action. When you assign an action to a button in Normal Mode, the on(mouse event)
handler is automatically inserted.
When you assign an action to a movie clip, you must nest the action inside an onClipEvent
handler and specify the clip event that triggers the action. When you assign an action to a movie clip in Normal Mode, the on(mouse event)
handler is automatically inserted.
The following instructions describe how to assign actions to objects using the Actions panel in Normal Mode.
Once you've assigned an action, use the Control > Test Movie command to test whether it works. Most actions won't work in Editing Mode.
To assign an action to a button or movie clip:
1 | Select a button or movie clip instance and choose Window > Actions. |
If the selection is not a button, a movie clip instance, or a frame, or if the selection includes multiple objects, the Actions panel is dimmed. | |
2 | Choose Normal Mode from the pop-up menu at the upper right of the Object Actions panel. |
3 | To assign an action, do one of the following: |
![]() |
Click the Actions folder in the Toolbox list on the left side of the Actions panel. Double-click an action to add it to the Actions list on the right side of the panel. |
![]() |
Drag an action from theToolbox list to the Actions list. |
![]() |
Click the Add (+) button and choose an action from the pop-up menu. |
![]() |
Use the keyboard shortcut listed next to each action in the pop-up menu.
![]() |
Selecting an object from the toolbox in Normal Mode |
|
4 | In the Parameters fields at the bottom of the panel, select parameters for the action as needed. |
Parameters vary depending on the action you choose. For detailed information on the required parameters for each action, see the ActionScript dictionary: Overview. To insert a Target path for a movie clip into a Parameter field, click the Target Path button in the lower right corner of the Actions panel. For more information, see Working with movie clips: Overview. | |
5 | Repeat steps 3 and 4 to assign additional actions as necessary. |
![]() |
To test an object action:
Choose Control > Test Movie.