MACROMEDIA DIRECTOR MX 2004-DIRECTOR SCRIPTING Reference page 35

Director scripting reference
Table of Contents

Advertisement

It must consist of one word or of several words connected by an underscore—no spaces
are allowed.
It must be different from the name of any predefined Lingo or JavaScript syntax element.
Using predefined Lingo or JavaScript keywords for message and handler names can create
confusion. Although it is possible to explicitly replace or extend the functionality of a Lingo or
JavaScript element by using it as a message or handler name, this should be done only in certain
advanced situations.
When you have multiple handlers with similar functions, it is useful to give them names that have
similar beginnings so they appear together in an alphabetical listing, such as the listing that can be
displayed by the Edit > Find > Handler command.
Handlers
A handler is a set of statements within a script that runs in response to a specific event and
subsequent message. Although Director contains built-in events and messages, you must create
your own custom handlers for each event/message pair that you want to handle.
Deciding where to place handlers
You can place handlers in any type of script, and a script can contain multiple handlers. It's a good
idea to group related handlers in a single place, though, for easier maintenance.
The following are some useful guidelines for many common situations:
To associate a handler with a specific sprite, or to have a handler run in response to an action
on a specific sprite, put the handler in a behavior attached to the sprite.
To set up a handler that should be available any time the movie is in a specific frame, put the
handler in a behavior attached to the frame.
For example, to have a handler respond to a mouse click while the playhead is in a frame,
regardless of where the click occurs, place a
behavior rather than in a sprite behavior.
To set up a handler that runs in response to messages about events anywhere in the movie, put
the handler in a movie script.
To set up a handler that runs in response to an event that affects a cast member, regardless of
which sprites use the cast member, put the handler in a cast member script.
Determining when handlers receive a message
After sending a message to scripts, Director checks for handlers in a definite order.
Director first checks whether a handler exists in the object from which the message was sent. If
1
a handler is found, the message is intercepted, and the script in the handler runs.
If no handler is found, Director then checks cast member, in ascending order, for any associated
2
movie scripts that might contain a handler for the message. If a handler is found, the message is
intercepted, and the script in the handler runs.
If no handler is found, Director then checks whether a frame script contains a handler for the
3
message. If a handler is found, the message is intercepted, and the script in the handler runs.
If no handler is found, Director then checks sprites, in ascending order, for any scripts
4
associated with the sprites that might contain a handler for the message. If a handler is found,
the message is intercepted, and the script in the handler runs.
or
mouseDown
mouseUp
Events, messages, and handlers
handler in the frame
35

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the DIRECTOR MX 2004-DIRECTOR SCRIPTING and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Director mx 2004

Table of Contents