
Playing sounds with Lingo or JavaScript syntax
235
Playing sounds with Lingo or JavaScript syntax
Lingo or JavaScript syntax lets you play and control sounds regardless of the settings in the Score.
You can use these scripts to play sounds, turn them on and off, and play external sounds that
aren’t cast members. Using script to play sounds lets you control the exact timing of when sounds
start and stop. Lingo or JavaScript syntax also lets you play only part of a sound cast member or
play several sounds in succession without interruption.
Sounds played by Director play at the volume that is set in the computer’s sound level control.
You can use Lingo or JavaScript syntax to modify the computer’s sound level to suit the needs of
your movie or to modify the volume of the sound channel.
You can also use Lingo or JavaScript syntax to control and stream Shockwave Audio. For more
information, see
“Playing Shockwave Audio, Windows Media Audio, and MP3 audio with Lingo
or JavaScript syntax” on page 239
.
Playing sound cast members
After you import a sound as a cast member, you can control many aspects of how the sound plays.
To play sound cast members regardless of the settings in the Score:
•
Use the
queue()
and
play()
methods. The
queue()
method loads the sound into the
Director RAM buffer so that it can be play immediately when called. The
play()
method
starts the sound playing. If you omit the
queue()
method, the sound might not play
immediately when called. For more information about these methods, see the Scripting
Reference topics in the Director Help Panel.
The following statements load the sound called Siren into RAM and start it playing in
sound channel 1:
sound(1).queue(member("Siren"))
sound(1).play()
To queue more than one sound to play in succession:
•
Use the
queue()
method to list sounds in the order you want them to play. If you queue them
before they play, Director plays the sounds with no pauses between the sounds. After the
sounds are queued, you need only one
play()
method.
These statements queue the sound members Explosion and Siren and play them in succession in
sound channel 2:
sound(2).queue(member("Explosion"))
sound(2).queue(member("Siren"))
sound(2).play()
To control how a queued sound plays:
•
Include optional parameters in a property list within the
queue()
method. For more
information about this method, see the Scripting Reference topics in the Director Help Panel.
When you use
setPlayList()
, any previously set queue of sounds is replaced by the
new playlist.
Summary of Contents for DIRECTOR MX 2004-USING DIRECTOR
Page 1: ...DIRECTOR MX 2004 Using Director...
Page 16: ...16 Chapter 1 Introduction...
Page 82: ...82 Chapter 3 Sprites...
Page 98: ...98 Chapter 4 Animation...
Page 134: ...134 Chapter 5 Bitmaps...
Page 242: ...242 Chapter 10 Sound and Synchronization...
Page 274: ...274 Chapter 11 Using Digital Video...
Page 290: ...290 Chapter 12 Behaviors...
Page 302: ...302 Chapter 13 Navigation and User Interaction...
Page 334: ...334 Chapter 15 The 3D Cast Member 3D Text and 3D Behaviors...
Page 392: ...392 Chapter 16 Working with Models and Model Resources...
Page 418: ...418 Chapter 18 Movies in a Window...
Page 446: ...446 Chapter 22 Managing and Testing Director Projects...