Chapter 31. Playing and Generating Sound

FEATURED CLASSES

  • flash.media.Sound

  • flash.media.SoundChannel

  • flash.media.SoundTransform

  • flash.media.SoundMixer

  • flash.media.ID3Info

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."

An Overview of the Sound System

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 flash.media package.

  • 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 Loader class, Sound encapsulates ...

Get ActionScript 3.0 Bible 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.