13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 24: Working with sound<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

ActionScript is made for immersive, interactive applications—and one oft<strong>en</strong> overlooked elem<strong>en</strong>t of powerfully<br />

immersive applications is sound. You can add sound effects to a video game, audio feedback to an application user<br />

interface, or ev<strong>en</strong> make a program that analyzes mp3 files loaded over the Internet, with sound at the core of the<br />

application.<br />

You can load external audio files and work with audio that’s embedded in a SWF. You can control the audio, create<br />

visual repres<strong>en</strong>tations of the sound information, and capture sound from a user’s microphone.<br />

More Help topics<br />

flash.media package<br />

flash.ev<strong>en</strong>ts.SampleDataEv<strong>en</strong>t<br />

Basics of working with sound<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

Computers can capture and <strong>en</strong>code digital audio—computer repres<strong>en</strong>tation of sound information—and can store it<br />

and retrieve it to play back over speakers. You can play back sound using either Adobe® Flash® Player or Adobe® AIR<br />

and ActionScript.<br />

Wh<strong>en</strong> sound data is converted to digital form, it has various characteristics, such as the sound’s volume and whether<br />

it is stereo or mono sound. Wh<strong>en</strong> you play back a sound in ActionScript, you can adjust these characteristics as well—<br />

make the sound louder, or make it seem to be coming from a certain direction, for instance.<br />

Before you can control a sound in ActionScript, you need to have the sound information loaded into Flash Player or<br />

AIR. There are five ways you can get audio data into Flash Player or AIR so that you can work with it using<br />

ActionScript.<br />

Load an external sound file such as an mp3 file into the SWF.<br />

Embed the sound information into the SWF file directly wh<strong>en</strong> it’s being created.<br />

Capture audio from a microphone attached to a user’s computer.<br />

Stream audio from a server.<br />

Dynamically g<strong>en</strong>erate and play audio.<br />

Wh<strong>en</strong> you load sound data from an external sound file, you can begin playing back the start of the sound file while the<br />

rest of the sound data is still loading.<br />

Although there are various sound file formats used to <strong>en</strong>code digital audio, ActionScript 3.0, Flash Player and AIR<br />

support sound files that are stored in the mp3 format. They cannot directly load or play sound files in other formats<br />

like WAV or AIFF.<br />

Last updated 6/6/2012<br />

441

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!