User Guide

Writing Scripts with Lingo 425
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
Using timeOutList
When you begin creating timeout objects, you can use
timeOutList to check the number of
timeout objects that are active at a particular moment.
The following statement sets the variable
x to the number of objects in timeOutList. See
count() in the Lingo Dictionary.
x = (the timeOutList).count
You can also refer to an individual timeout object by its number in the list.
The following statement deletes the second timeout object in
timeOutList. See forget() in the
Lingo Dictionary.
timeOut(2).forget
Relaying system events with timeout objects
When you create timeout objects that target specific child objects, you enable those child objects
to receive system events. Timeout objects relay these events to their target child objects. The
system events that can be received by child objects include
prepareMovie, startMovie,
stopMovie, prepareFrame, and exitFrame. By including handlers for these events in child
objects, you can make the child objects respond to them for whatever purposes you see fit. System
events received by child objects are also received by movie scripts, frame scripts, and other scripts
designed to respond to them.
This parent script contains a handler for the system event
exitFrame as well as a custom handler:
property velocity
on new me
velocity = random(55)
end
on exitFrame
velocity = velocity + 5
end
on slowDown mph
velocity = velocity - mph
end
For information on specific timeout properties, see timeout() in the Lingo Dictionary.