S > Sound (object) |
![]() ![]() ![]() |
Sound (object)
The Sound object lets you control sound in a movie. You can add sounds to a movie clip from the Library while the movie is playing and control those sounds. If you do not specify a target
when you create a new Sound object, you can use the methods to control sound for the whole movie. You must use the constructor new Sound
to create an instance of the Sound object before calling the methods of the Sound object.
The Sound object is supported in Flash Player 5 and Flash Player 6.
Method Description Attaches the sound specified in the parameter. Returns the number of bytes loaded for the specified sound. Returns the size of the sound in bytes. Returns the value of the previous Returns the value of the previous Returns the value of the previous Loads an MP3 file into the Flash Player. Sets the left/right balance of the sound. Sets the amount of each channel, left and right, to be played in each speaker. Sets the volume level for a sound. Starts playing a sound from the beginning or, optionally, from an offset point set in the parameter. Stops the specified sound or all sounds currently playing.
Method summary for the Sound object
setPan
call.
setTransform
call.
setVolume
call.
Method Description Length of a sound in milliseconds. Number of milliseconds the sound has been playing.
Property summary for the Sound object
Method Description Invoked when a sound loads. Invoked when a sound stops playing.
Event handler summary for the Sound object
Constructor for the Sound object
Availability
Flash Player 5.
Usage
new Sound([target
])
Parameters
target
The movie clip instance on which the Sound object operates. This parameter is optional.
Returns
Nothing.
Description
Constructor; creates a new Sound object for a specified movie clip. If you do not specify a target instance, the Sound object controls all of the sounds in the movie.
Example
The following example creates a new instance of the Sound object called GlobalSound
. The second line calls the setVolume
method and adjusts the volume on all sounds in the movie to 50%.
globalsound = new Sound();
globalsound.setVolume(50);
The following example creates a new instance of the Sound object, passes it the target movie clip myMovie
, and calls the start
method, which starts any sound in myMovie
.
moviesound = new Sound(
myMovie
);
moviesound.start();
![]() ![]() ![]() |