User Guide
62 Chapter 3: Writing Scripts in Director
To add an object to the actorList:
• Use the actorList property as follows, where childObject is a reference to the child object
to add:
-- Lingo syntax
_movie.actorList.add(childObject)
The object’s stepFrame handler in its parent or ancestor script then runs automatically each
time the playhead advances. The object is passed as the first parameter,
me, to the on
stepFrame
handler.
Director does not clear the contents of
actorList when branching to another movie, which can
cause unpredictable behavior in the new movie. If you do not want child objects in the current
movie to be carried over into the new movie, insert a statement that clears
actorList in the on
prepareMovie
handler of the new movie.
To clear child objects from actorList:
• Set actorList to [ ], which is an empty list.
For reference information on
actorList, see “actorList” on page 625.
Creating timeout objects
A timeout object is a script object that acts like a timer and sends a message when the timer
expires. This is useful for scenarios that require specific things to happen at regular time intervals
or after a particular amount of time has elapsed.
Timeout objects can send messages that call handlers inside child objects or in movie scripts. You
create a timeout object by using the
new() keyword. You must specify a name for the object, a
handler to be called, and the frequency with which you want the handler to be called. After a
timeout object is created, Director keeps a list of currently active timeout objects, called
timeOutList.
The syntax described below is necessary for all new movies authored in Director MX 2004, or for
older movies playing in Director MX 2004 whose
scriptExecutionStyle property has been set
to a value of 10. Movies authored in Director MX and earlier have a
scriptExecutionStyle
property set to a value of 9 which allows you to use the syntax found in Director MX and earlier.
To create timeout objects:
-- Lingo syntax when scriptExecutionStyle is set to 9
variableName = timeout(name).new(timeoutPeriod, timeoutHandler,
targetObject)
-- Lingo syntax when scriptExecutionStyle is set to 10
variableName = timeout().new(timeoutName, timeoutPeriod, timeoutHandler,
targetObject)
variableName = new timeout(timeoutName, timeoutPeriod, timeoutHandler,
targetObject)
// JavaScript syntax
variableName = new timeout(timeoutName, timeoutPeriod, timeoutFunction,
targetObject)