Using Director > Parent Scripts > Creating timeout objects |
![]() ![]() ![]() |
Creating timeout objects
You can create a timeout objecta 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 following syntax:
variableName
= timeOut("theName
").new(integerMilliseconds
, #handlerName
,targetObject
)
This statement uses the following elements:
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
This statement creates a timeout object named timer1
that will call the on accelerate
handler in the child object car1
every 2 seconds:
myTimer = timeOut("timer1").new(2000, #accelerate, car1)
To determine when the next timeout message will be sent from a particular timeout object, check its #time
property. The value returned is the point in time, in milliseconds, when the next timeout message will be sent.
This statement determines the time when the next timeout message will be sent from the timeout object timer1
and displays it in the Message window:
put timeout("timer1").time
![]() ![]() ![]() |