Scripting Sound in Flash MX
Use the controls in the movie below to stop the sound when it becomes annoying.
There are 70 frames in this animation, with a frame rate of 10 fps. The file size is 64 KB. The size of the MP3 file before importing to Flash: 28 KB.

> Return to Flash examples list.

This Flash movie had the sound added to it with ActionScript. This is a lot easier than messing with the Timeline, I think.

After you import the sound file to Flash MX, you use Linkage (right-click the sound file in the Library) to make the file available for scripting. This is all explained in the Help files on a page titled "Creating sound controls."

The buttons can be any generic buttons. You script them as you would any button. The sound can loop, or not. It's easy to make the sound start and stop again. If it was one long sequence of sound (instead of an ambient loop), you would have to use some more complex scripting to figure out where in the sound file it had stopped. > See how to script everything.

The thing to notice at left is how the movie keeps playing when you stop the sound and -- maybe more important -- how the sound keeps playing when you stop the movie! Of course, there are ways to fix that.

This animation illustrates some of the things you must consider when adding buttons to a Flash movie that includes sound. They may not do everything you intend them to do, so you must test them -- a lot.