How to Use Flash MX Sound Objects

This document copyright © 2004 by Kenny Bellew of Cowfly.Com Design, kennybellew@hotmail.com
How to Troubleshoot Sound Objects Return to Index Do you want all FLA's used for this tutorial? Do you have a question?

Most problems experienced with sound objects involve a sound object that won't start or, when you try to stop one, more sounds stop than was intended. If a sound will not start, here are a few things to check:

Sound Will Not Start

  1. Make sure that the proper path to the sound object is included in the start command. The proper path is wherever the sound object was defined. For example, if the sound object is defined in a button located in a movie clip named "mc02" which is in another movie clip called "mc01", the ActionScript would appear as follows:                             
on (press) {      _root.mc01.mc02.mySoundObject.start();        }
 

As stated earlier, if the sound objects are all defined in one frame on the _root, the path would always be the same, and this would not be something you didn't need to track.
 

  1. If you're trying to start a dynamically loaded MP3 that is configured as streaming with the mySoundObject.start() method, and it will not start, the Flash player probably needs to be updated to the latest version.

     
  2. For non-dynamically loaded sound objects, make sure that the linkage identifier is properly typed - both where the sound object was defined and in the linkage properties in the Flash library. Also make sure that the identifier is a unique name. Remember that names are case sensitive and cannot start with a number.  Check for typos.
  3. If you set a condition for the sound to start when another condition becomes true (like it reaches _totalFrames, it reaches total duration, onSoundComplete, etc.), and you are loading a sound into the same container as the previous sound (like a movie clip) or the same sound object, you cannot expect it to unload the first sound (in the case of loadMovie), load the new sound and start the new sound on the same frame (for example, when using the clip events of a movie to control the sound). This does not pertain to basic starting and stopping. This pertains to a more complex configuration as described above. The solution is to put a few frames between the unloading of the first sound and the loading of the next sound. An easy way to do this is so drop a movie on stage (to use its timeline), and instead of using the start command in the same frame you unload the previous sound, send the timeline to a location in the new movie clip where it will find the start command for the new sound. This is especially true when using loadMovie or loadSound.
     

Stopping one Sound Stops Multiple Sounds

This is nearly always due to how or where the sound object was defined.  One easy way to resolve this is to specify the linkage identifier name as part of the stop command:

mySoundObject.stop("mySoundObject01");

In the above example, "mySoundObject01" is the linkage identifier name that is set in the Flash library by right-clicking (or control-clicking for Macs) on the sound file and selecting "Export for ActionScript".

Sound Object Error Messages

Sounds Play Too Fast and Sound like "the Chipmunks"

This occurs if you are attempting stream audio that does not comply with the allowable sampling rates. Make sure that your audio complies with the sampling rates allowed by Flash streaming audio, which are: 44.1, 22 and 11kHz. These numbers refer to the number of samples per second, not to be confused with the bitrate (which is measured in Kbps, e.g., commonly seen as 128 KB).

Miscellaneous Sound Object Issues

There is currently a limitation of having no more than eight sounds playing simultaneously.  To read more on this issue, visit this link: http://www.macromedia.com/support/flash/ts/documents/soundmax.htm.

Previous Next
How to Maintain Sound Object Properties Across Multiple Scenes Passing Variables from HTML to Flash to Select which MP3 will Play
Return to Index Do you want all FLA's used for this tutorial? Do you have a question?

This document copyright © 2004 by Kenny Bellew of Cowfly.Com Design, kennybellew@hotmail.com