Chapter 3
180
delay
Syntax
delay
numberOfTicks
Description
Command; pauses the playhead for a given amount of time. The integer expression
numberOfTicks
specifies the number of ticks to wait, where each tick is 1/60 of a second. The
only mouse and keyboard activity possible during this time is stopping the movie by pressing
Alt+period (Windows) or period (Macintosh). Because it increases the time
of individual frames, the
delay
command is useful for controlling the playback rate of a
sequence of frames.
The
delay
command can be applied only when the playhead is moving. However, when
delay
is
in effect, handlers still run: only the playhead halts, not script execution. Place scripts that use the
delay
command in either an
on enterFrame
or
on exitFrame
handler.
To mimic the behavior of a halt in a handler when the playhead is not moving, use the
startTimer
command or assign the current value of
timer
to a variable and wait for the specified
amount of time to pass before exiting the frame.
Examples
This handler delays the movie for 2 seconds when the playhead exits the current frame:
on exitFrame
delay 2 * 60
end
This handler, which can be placed in a frame script, delays the movie a random number of ticks:
on keyDown
if the key = RETURN then delay random(180)
end
Example
The first of these handlers sets a timer when the playhead leaves a frame. The second handler,
assigned to the next frame, loops in the frame until the specified amount of time passes:
--script for first frame
on exitFrame
global gTimer
set gTimer = the ticks
end
--script for second frame
on exitFrame
global gTimer
if the ticks < (10 * 60) then
go to the frame
end if
end
See also
startTimer
,
ticks
,
timer
Содержание DIRECTOR MX-LINGO DICTIONARY
Страница 1: ...Lingo Dictionary Macromedia Director MX...
Страница 756: ...Index 756...