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)
Summary of Contents for DIRECTOR MX 2004-DIRECTOR SCRIPTING
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...