Events, Messages, And Handlers - MACROMEDIA DIRECTOR MX 2004-DIRECTOR SCRIPTING Reference

Director scripting reference
Table of Contents

Advertisement

Events, messages, and handlers

A key component to creating powerful, useful scripts is an understanding of the concepts and
functionality of events, messages, and handlers. Understanding the order in which events and
messages are sent and received will help you determine exactly when specific scripts or parts of
scripts should run. It will also help you debug scripts when specific actions are not occurring
when you expect them to occur.
When a movie plays, the following occurs:
Events occur in response to either a system or user-defined action
1
Messages that correspond to these events are sent to the scripts in a movie
2
Handlers within scripts contain the instructions that run when a specific message is received
3
The name of an event corresponds to the name of the message it generates, and the handler that
handles the event corresponds to both the event and the message. For example, when the event
named
mouseDown
which would in turn be handled by a handler named
Events
There are two categories of events that occur when a movie plays:
System events
named in Director. For example, when the playhead enters a frame, when a sprite is clicked,
and so on.
User-defined events
create an event that occurs when the background color of a sprite changes from red to blue,
when a sound has played five times, and so on.
Many system events, such as
in a predefined order while a movie is playing. Other system events, particularly mouse events
such as
mouseDown
playing, but rather when a user triggers them.
For example, when a movie first starts, the
event always occurs second, and so on. However, the
prepareFrame
events may never occur in a movie unless a user triggers them by clicking the movie.
The following lists illustrate the system events that always occur during a movie, and the order in
which they occur.
When the movie first starts, events occur in the following order:
1
prepareMovie
2
prepareFrame
sprites, and performs any transitions or palette effects. This event occurs before the
event. A
prepareFrame
frame draws.
3
beginSprite
4
startMovie
occurs, Director generates and sends to scripts a message named
occur without a user interacting with the movie, and are predefined and
occur in response to actions that you define. For example, you could
prepareFrame
,
, and so on, do not necessarily occur automatically while a movie is
mouseUp
Immediately after the
handler is a good location for script that you want to run before the
This event occurs when the playhead enters a sprite span.
This event occurs in the first frame that plays.
mouseDown
,
, and so on, occur automatically and
beginSprite
event always occurs first, the
prepareMovie
event, Director plays sounds, draws
prepareFrame
Events, messages, and handlers
mouseDown
.
and
mouseDown
mouseUp
enterFrame
,
33

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Director mx 2004

Table of Contents