How to Use Flash MX Sound Objects

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

Flash has a built-in difficulty with looping MP3 sounds. There is often a slight pause between the end of the sound and the restarting of the sound. Read Macromedia's take on this in their article, "Why do my looping sounds pause between loops?"

That said, it is also true that there is an art to creating sounds that loop well. The way that the sound is edited can create sounds that seem to loop with less apparent pause. The art of creating sounds that loop well is similar to the art of creating images that tile seamlessly. I am not an expert in this art, but the following code may help reduce the pause in sounds that loop poorly due to unwanted silence at the beginning of an audio file.

// Sound Object
myLoop = new Sound();
myLoop.attachSound("myLoop01");
myLoop.start(0,0);
myLoop.onSoundComplete = function() {
myLoop.start(.1, 0);
};

The above code uses the start command to start the sound in a non-looping call, and, when the sound completes, instructs it to start a tenth of a second from the beginning position of the sound object. The sound will continue to repeat (loop) in this manner until it is stopped. As previously discussed, the sound object position can be affected in milliseconds, so you could, in theory, tweak the start time within milliseconds. However, there is a point of diminishing returns that you will find very quickly. This method is not perfect. It is only one more tool to help you find the sound you need.

I have tried taking two instances of the same loop, starting the second instance milliseconds before the first instance ends (looping back and forth using the onSoundComplete event handler). However, a strange creep in volume amplitude occurs over time.

Previous Next
How to Invoke Actions When a Sound Object Ends How to Synchronize Animation to a Specific Time within a Sound Object
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