• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 13. Interactivity with Objects > Adding Actions to Movie Clips

Adding Actions to Movie Clips

Just as you can at ach ActionScripts to button instances, you can at ach ActionScripts to movie-clip instances. Movie-clip ActionScripts have a default handler— onClipEvent —that encompasses its own set of event parameters. The onClipEvent handler can respond to mouse events (such as pressing the mouse button or moving the mouse), keyboard activity (such as pressing a certain key), the activity of the movie clip itself (such as loading into the main Timeline), and the receipt of data (from variables).

To add an event handler to a movie-clip instance:

1.
Open a new document.

2.
In Frame 1, place an instance of a movie-clip animation on the Stage.

3.
Select the movie-clip instance.

4.
Access the Actions panel.

The panel’s title bar changes to Actions-Movie Clip.

5.
From the Add menu, choose Actions > Movie Clip Control > onClipEvent.

Flash places the default movie-clip handler onClipEvent (load); and a pair of curly braces in the Script pane (Figure 13.40).

Figure 13.40. With a movie clip selected on the Stage, when you choose Actions > Movie Clip Control > onClipEvent from the Actions panel’s Add menu, Flash adds the default movie-clip event handler onClipEvent (load) to the Script pane. This handler causes the script to trigger when the clip loads.


The default movie-clip event handler tells Flash to implement the ActionScript within the braces as soon as the movie clip loads into the frame containing it (in this case, Frame 1) during playback of the movie.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint