Using Sound Objects

 < Day Day Up > 



So far you've attached sound to the Timeline. By using Sound objects you can use ActionScript to access the sound even if it isn't in the Timeline. A Sound object is a predefined ActionScript object, which contains the information about the movies sounds and its properties. Objects have properties, which are variables that contain data. By attaching a Sound object to a sound you can pass information from it to the sound. The Sound object has methods (which can be applied to unique instances of the object), which send and retrieve information about your movie and its objects. The Sound object has methods, which set and check values, panning, play, and stop actions. Sound objects can control the following:

  • All sounds loaded in the current movie

  • All sounds currently available in the Flash Player

  • Sounds in a specific Movie Clip

  • A specific sound the object is attached to

The generic constructor for a Sound object is

SoundObjectName=new Sound("targetInstance");

In Chapter 26, you learned about Movie Clip objects and in Chapter 28 you learned about the Array, Math, and TextField objects. The Sound objects (as well as the Color and Date objects) are a bit less forgiving than the others and require formal rules. The sound object needs to be instantiated using a constructor function such as the following one:

newObject(); for sound it's newSound(); 

Using newSound() doesn't really do anything. You need to store the object in a variable. By using mySound=newSound() you create a new instance of the Sound object and place it into the variable mySound. mySound can be referred to by its properties or by using a method (mySound.someProperty or mySound.someMethod()). The thing to remember is that you need to instantiate an object and place it in a variable before you can do anything with it.



 < Day Day Up > 



Macromedia Studio MX Bible
Macromedia Studio MX Bible
ISBN: 0764525239
EAN: 2147483647
Year: 2003
Pages: 491

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net