Movie Clip Events Overview
Movie clip events are generated by a wide variety of occurrences in the Flash Player, from mouseclicks to the downloading of data. Clip events can be broken into two categories: user-input events and movie-playback events. User-input events are related to the mouse and keyboard, while movie-playback events are related to the rendering of frames in the Flash Player, the birth and death of movie clips, and the loading of data.
Note that user-input clip events partially overlap the functionality
of the button events described earlier. For example, a clip’s
mouseDown
event handler can detect a mouse press
just as a button’s press
event handler
can. Movie clip events, however, are not tied to any kind of
hit area like button events are and do not
affect the look of the mouse pointer.
Let’s spend some quality time with the ActionScript movie clip
events, summarized in Table 10.2. We’ll look
at the movie-playback events first (enterFrame
,
load
, unload
, and
data
) and then see how the user-input events
work (mouseDown
, mouseUp
,
mouseMove
, keyDown
,
keyUp
). Each of the clip events is handled by a
matching clip event handler of the form
onClipEvent
(eventName
). For example, the
enterFrame
event is handled using an event
handler beginning with onClipEvent (enterFrame)
.
With the exception of load
,
unload
, and data
, movie
clip events are sent to all movie clips on stage even if, say, the user clicks the mouse while on top of a different movie clip (or no movie clip). ...
Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.