Lingo Alternatives to the Tempo Channel
The tempo channel is intended for straightforward, simple presentations. When your movie gets more more sophisticated, it is a better to use Lingo to replace any of the Temp settings.
Changing the Tempo (FPS)
Placing the following in a frame script will set the
tempo to 15 fps.
on exitFrame
-- set the tempo to 15 frames per second (fps)
puppetTempo 15
end
Creating a Wait (secs)
The following causes a 2 second
delay. In Director, time is measured in ticks where 60 ticks = 1 second.
This script, however, may cause inteference with interactivity, and so in
not the best way to create a pause.
on exitFrame
-- wait 2 seconds
delay
2*60
end
Here is a better way to have create delay. Using a repeat loop prevents
other activities from occuring (e.g. mouseDown
and keyDown events), as only one handler can execute
at a time.
on enterFrame
startTimer -- sets the timer to zero
repeat while the timer
< 2*60
updateStage
end repeat
end
or using milliseconds
-- set property variable to store starting time
property
pStartTime
on beginSprite
pStartTime = the milliseconds
end
on exitFrame
if (pStartTime - the milliseconds) < 2*1000 then \
go the frame
end
The above is probably the best option as using a repeat loop, means you
lock Director into a paused state during that loop and only what you specify
in the loop will occur. But, if that's what you want to happen, then...
Wait for Mouse Click or Key Press
The following toggles the cursor between the 2 "press mouse" cursors every
3/4 second.
on exitFrame
-- imitate the flashing wait cursor
cursor
282 + (the timer/45)mod 2
go the frame
endon mouseDown
-- change back the cursor to an arrow
cursor
-1
go the frame + 1
end on keyDown
-- change back the cursor to an arrow
cursor
-1
go the frame + 1
end
Wait for End of Sound in Channel X
Placing the following in a score script will cause the movie to keep playing
the frame until the sound is finished. on exitFrame
-- loop the frame while sound plays
if
soundBusy(X) then go the frame
end
Where X is the sound channe.
With Director MX 2004, Sound Lingo has changed, and so the above script
could now be written
on exitFrame
if
sound(X).isBusy() then go the frame
end
Working with Cue Point(s)
Cue points are useful in synchronizing sound, QuickTime and animation. Cue
points can be placed in audio or Digital Video files using Sound Edit16,
available for the Macintosh, and used in Director movies on both platforms.
The following properties and commands are available:
on cuePassed - can be used to execute
code after a cue point has been passed.
on cuePassed channel,
number, name
if name
= "CuePoint1" then
alert name &&
"passed"
end if
end
mostRecentCuePoint - identifies the
most recent cue point passed in the sprite. This cannot be used on a sound
in the sound channel and should therefore be used only with media elements
that are placed in sprite channels in the score.
on testCue
theCue = sprite(1).mostRecentCuePoint
if theCue = 1 then
alert "Cue 1 passed!"
end if
end
isPastCuePoint(whichSpriteOrSound, cuePointID)
- returns the number of times a specified cue point in a file has been passed
on a given loop-through.
on exitFrame
if isPastCuePoint(1, "plug 1") then
alert "is past plug 1"
end if
end
cuePointTimes of member - returns a
list of all times of cue points of a specified member in milliseconds.
put the cuePointTimes of member "Schatzi"
-- [0, 4231, 6875, 12985, 18391, 21003]
cuePointTimes of member - returns a list of names
of all cue points of a specified member.
put the cuePointNames of member "Schatzi"
-- [sniffy, snappy, bitey, drooly]
Wait for End of Digital Video in Channel X
The following frame script will loop the in the frame while the digital
video in channel X is lower than the cast member's (Y) duration.
on exitFrame
if sprite(X).movieTime < cast(Y).duration then \
go the frame
end
Director uses a Direct to Stage option for digital video. This may need
you to erase the digital video once it has finished playing. Either of the
following 2 scripts can be used.
on exitFrame
if sprite(X).movieTime < cast(Y).duration then
go the frame
else
-- Make the digital video sprite invisible.
-- This property would need to be reset upon
-- entering the next frame.
sprite(X).visible = 0
end if
end on exitFrame
if sprite(X).movieTime < cast(Y).duration then
go the frame
else
-- use a transition to force Director to redraw the
-- screen
puppetTransition 23
end if
end