Chapter 16
424
The object’s
on stepFrame
handler in its parent or ancestor script will then run automatically
each time the playhead advances. The object will be passed as the first argument (that is, the
me
argument) to the
on
stepFrame
handler.
Director doesn’t clear the contents of
actorList
when branching to another movie, which can
cause unpredictable behavior in the new movie. If you don’t 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 more information, see
actorList
and
on stepFrame
in the Lingo Dictionary.
Creating timeout objects
You can create a timeout object—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()
function. 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. Once a
timeout object is created, Director keeps a list of currently active timeout objects, called
timeOutList
.
To create timeout objects:
•
Use the syntax
variableName
= timeOut(“
theName
”).new(
integerMilliseconds
,
#handlerName
,
targetObject
)
This statement uses the following elements:
•
variableName
is the variable you are placing the timeout object into.
•
timeOut
indicates which type of Lingo object you are creating.
•
theName
is the name you give to the timeout object. This name will appear in the
timeOutList
. It is the
#name
property of the object.
•
new
is the Lingo function that creates a new object.
•
integerMilliseconds
indicates the frequency with which the timeout object should call the
handler you specify. This is the
#period
property of the object. A value of 2000 will call the
specified handler every 2 seconds.
•
#handlerName
is the name of the handler you want the object to call. This is the
#timeOutHandler
property of the object. You represent it as a symbol by preceding the name
with the # sign. For example, a handler called
on accelerate
would be specified as
#accelerate
.
•
targetObject
indicates which child object’s handler should be called. This is the
#target
property of the object. It allows specificity when many child objects contain the same handlers.
If you omit this parameter, Director will look for the specified handler in the movie script.
Summary of Contents for DIRECTOR MX-USING DIRECTOR MX
Page 1: ...Using Director MX Macromedia Director MX...
Page 12: ...Contents 12...
Page 156: ...Chapter 4 156...
Page 202: ...Chapter 6 202...
Page 244: ...Chapter 7 244...
Page 292: ...Chapter 10 292...
Page 330: ...Chapter 12 330...
Page 356: ...Chapter 13 356...
Page 372: ...Chapter 14 372...
Page 442: ...Chapter 16 442...
Page 472: ...Chapter 18 472...
Page 520: ...Chapter 19 520...
Page 536: ...Chapter 20 536...
Page 562: ...Chapter 23 562...
Page 566: ...Chapter 24 566...
Page 602: ...Chapter 27 602...