Chapter 8. Using Sound

Used carefully, sound can dramatically enhance an animation or interactive experience. Music can be used for animation soundtracks, and sound effects can add a touch of realism to an animation or a bit of life to an interface. However, it’s important to remember that sound doesn’t usually come without a price. Sound files can contribute significantly to the size of a SWF, and sound can be overused or used gratuitously, detracting from the overall effect. The task, therefore, is to know how and when to use sound for maximum impact.

Importing Sounds

There are two primary ways to use sound in Flash. The first is by importing a sound into Flash so that it is distributed as part of the compiled .swf file. The second is by loading an external sound at runtime using ActionScript. In most cases, your project will be better served by loading external sounds during playback. This helps keep the size of your main .swf down and makes it easier to update your project.

However, there are some cases where internal sound is preferred. Perhaps the most common need for internal sound is when you want to try to synchronize audio and visual assets. Another example is when you don’t know enough ActionScript to load the sounds yourself and you are not satisfied with using a Flash component. Finally, you may need to confine your project to a single .swf for use in content management ...

Get Flash 8: Projects for Learning Animation and Interactivity now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.