• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Part III: Building Blocks/Introducing Ac... > Controlling Sound Using the Sound Ob...

Chapter 18. Controlling Sound Using the Sound Object

If you’re looking for a way to precisely control the sound in your Flash movies, the Sound object is a great choice. You can use the Sound object to attach and control sounds in any timeline of your movie.

In previous versions of Flash, after the Flash movie left the editing environment and ended up in a browser (or desktop), users were limited to just starting and stopping sounds. End users had no control over the volume or pan (left-right balance) of a sound, unless they had access to the FLA file and were able to use the Sound controls to modify those settings. The Sound object enables you to give your end users control over sound.

You can use this capability to create some very interesting effects. For example, you can create a real volume control that enables you to change the volume of a sound as it plays, instead of making the sound restart at a different volume as you had to do in previous versions of Flash. You can create custom cursors that not only follow the mouse graphically, but also aurally, with volume and pan control over a sound attached to the cursor.

The Sound object has a number of methods, which are covered in this chapter:

  • attachSound. Attaches a sound to the Sound object.

  • start. Starts the attached sound.

  • stop. Stops the attached sound. This method can be used to stop all the sounds in the movie.

  • setVolume. Sets the volume of an attached sound. This method also can be used to set the volume of all sounds playing in the movie at the time the method is applied.

  • getVolume. Returns the value of the current volume setting of a sound.

  • setPan. Sets the pan of an attached sound or all the sounds currently playing in the movie.

  • getPan. Returns the current pan value of a sound.

  • setTransform. Sets the transform for an attached sound. This enables you to specify the amount of left-right input that should be played in each speaker (left and right).

  • getTransform. Returns the current transform value for a sound.

Before you can use these methods, though, you need to create a new Sound object.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint