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 = ve 5
end
on slowDown mph
velocity = velocity - mph
end
For information on specific timeout properties, see
timeout()
in the Lingo Dictionary.
Содержание Director MX
Страница 1: ...Using Director MX Macromedia Director MX ...
Страница 12: ...Contents 12 ...
Страница 156: ...Chapter 4 156 ...
Страница 202: ...Chapter 6 202 ...
Страница 244: ...Chapter 7 244 ...
Страница 292: ...Chapter 10 292 ...
Страница 330: ...Chapter 12 330 ...
Страница 356: ...Chapter 13 356 ...
Страница 372: ...Chapter 14 372 ...
Страница 442: ...Chapter 16 442 ...
Страница 472: ...Chapter 18 472 ...
Страница 520: ...Chapter 19 520 ...
Страница 536: ...Chapter 20 536 ...
Страница 562: ...Chapter 23 562 ...
Страница 566: ...Chapter 24 566 ...
Страница 602: ...Chapter 27 602 ...