Sound is a powerful tool. A little bit of well-chosen sound goes a long way in adding depth and character to your Flash application. In this section, I look at ways to integrate sound into your program.
Through the past few versions, Flash Player has iterated on its sound support, making it far more robust. You can play SWF-embedded sound and load and stream MP3s. You can mix sounds, pan, and fade them. You can get a spectrum of the audio coming out of Flash Player for audio visualization. In Flash Player 10 and above, you can even sample sounds and generate your own dynamically. I'll cover all these in this chapter.
Flash Player also gives you access to audio coming in from the user's microphone or other audio input. This is covered in Chapter 33, "Capturing Sound and Video."
I'll tackle the sound system task by task. Before you start playing sounds, however, let's take a quick birds-eye view of the sound architecture in Flash Player. A few classes work in concert, handling different aspects of playing and mixing sounds. All these classes belong to the
Sound — Represents sound data. When you're going to play sounds in Flash Player, you always start with a
Sound object. Instances of this class hold, load, buffer, and accept audio data. Like the
Sound encapsulates ...