13audio plays as critical a part in interactive experiences as motion and graphics. unfortunately, it's often overlooked. but audio in flash is easy to work with.
at the simplest level, audio files (AIFF, AU, MP3, WAV) can be imported directly into the library
and dragged onto the stage for a specific frame. the timeline shows a visual representation of the sound,
which is great for synching animation. the sound will start playing when the playback head reaches its first frame,
and continue playing until done (regardless of where the playback head goes).
selecting a timeline frame updates the properties panel with a sound drop-down, which can be used to select sounds from the library instead of having to drag them onto the stage, and the properties panel also provides a simple way to tell a sound to loop, or apply a simple effect like fade-in.
sounds placed on different layers will play simultaneously. flash can play up to 32 simultaneous sound channels (stereo sounds occupy two channels).
swf]
[fla]
swf]
[fla]
while convenient and immediate, directly placing sounds from the library onto the stage has its limitations.
for instance, buttons have no frame for the onRollOut event. and you don't have any control
over the properties of the sound, such as its volume, pan, and duration. a sound placed on the stage will
play as loud as it was created, for as long as the sound lasts, centered between the left and right speakers.
to provide control over these properties and more, flash gives us the actionscript Sound object.
for every sound that will play simultaneously, you need two things:
Sound instance that represents the audio dataSoundChannel instance that represents the audio data playing in a sound channel
sounds that will be attached from the library need to be set to Export for Actionscript,
and have a linkage name (class name) specified.
var honk:Sound = new HonkSound(); var honkChannel:SoundChannel = honk.play();
SoundTransform class, which the SoundChannel has an instance of in its soundTransform property.
similar to graphics, avoid infringing on other's copyrights. befriend a musician or find freely available work.
keep an eye on your filesize; flash has some good compression technology built in,
but using lots of long sounds can quickly make an .swf that's sluggish to download.
you'll rarely find a sound that is just right. the volume may be too loud, the ending too harsh, the beginning too delayed, etc. most all sounds that you gather from external resources will need some sort of tweaking to make just right.
for this class, audacity is a free, easy to use sound editor that handles all the tweaking tasks you generally face, and can be handy for creating boops and beeps with its tone generator.