2. Introduction
Audio has long been an important part of the Flash world for
designers and developers alike.
well-planned sound can add a lot to games, applications, and
demos.
From a programming standpoint, ActionScript 3.0 introduces a whole
new
level of sound management. It’s now possible, for example, to more
easily
control Flash’s 32 independent channels of audio, determine the
amplitude
of mono and stereo sounds, and control Flash properties based on
data from
sounds playing in real time.
3. Introduction
Even without ActionScript, Flash is no
slouch in the audio department. You can
add sounds to animation and button
timelines, play them while down-loading,
and even edit them to a minimal degree,
right within Flash.
4. Supported File Formats
For a complete picture of Flash’s support
for file formats, this discussion is divided
into two categories: importing
audio, which is also often referred to as
embedding audio, and loading external
sounds for playback at runtime.
5. Importing Audio
You can import a variety of file formats into
Flash, which supports uncom-pressed and
compressed sound. The most common
formats are WA V, AIFF, and MP3; all three are
supported on both Windows and Mac.
WAV and AIFF files are typically used for
uncompressed sounds, although you can use
compression when creating both formats.
MP3 files are for compressed sounds .
6. Importing Audio
Importing a sound is the same as
importing graphical assets, with one
exception. Because there is no visual
component to an audio file, the Import to
Stage option functions just like the Import
to Library option.
7. Compression
Some Flash designers feel that it’s best to
import uncompressed sounds (such as
uncompressed WAVE or AIFF files) and
then let Flash compress the audio when
compiling to SWF.
Othersprefer to compress sounds using
external tools (saving to MP3) and then
apply no further compression in Flash.
8. Compression
Usinguncompressed sounds reduces or
eliminates artifacts that might otherwise
have been exacerbated by compressing
already compressed sound.
Using compressed sounds means slimmer
FLA files, but it reduces quality when you
want to change compression settings
later on.
9. Internal Asset-Specific Sound
Properties
Default
Default skips asset-specific compression and applies the file-wide compression options
explained in the upcoming section, “Internal File-Wide Publish Settings.”
ADPCM
applies a 4:1 compression ratio that allows you to choose not only sample rate, but also the
number of bits used during compression. This is also known as IMA or IMA ADPCM in QuickTime
environments.
MP3
MP3uses the MPEG-1 Audio Layer 3 compression algorithm and allows
you to customize preprocessing, bitrate, and quality settings.
Raw
Rawapplies no further compression. This is useful when you want to
import compressed sounds.
Speech
The Speech codec is optimized for speech and is not commonly suitable
for music. It is also not compatible with Flash Lite, the Flash Platform’s
player for mobile devices.
10. Timeline Use
select the frame where you want to add
the sound
Click and drag the sound from the library
11. Sync Types
The Sync type you set in the Properties panel for a Timeline-based
sound will have a dramatic effect on how the sound plays.
Stream
Stream sounds begin playing after just a few frames of data have
been downloaded. They are best for long sounds and are well suited
for animation soundtracks because Flash attempts to keep the
Timeline and sound synchronized.
Event
Event sounds must be fully downloaded and play through to
completion no matter what. For example, if a one-second sound
ordinarily requires 24 frames to play through to completion, an Event
sync type will cause that sound to play until complete, even if only
allocated one frame.
12. Sync Types
Start
The Start sync type is similar to Event in every respect
but one. If the play-head returns to the frame before
a prior instance of the sound is finished playing, it will
not play another instance of the sound.
Stop
The Stop sync type silences the specified sound. This
will even work on Event sounds that are designed
not to stop until they are finished playing.
13. Editing a Sound
Flash lets you do some basic volume and pan
editing without having to use an external
editor.
The Effect menu in the Properties panel
contains a list of preset effects, including
confining the sound to the Left channel or
Right channel, channel panning options
(Fade to left and Fade to right), and multi-
channel volume fades (Fade in and Fade
out).
14. Do this!
Step 1
Create a new flash document, take the Rectangle Tool (R) and create a shape that would represent a button.
Step 2
Take the Text Tool (A), and type: sound on, on the button.
Step 3
Select the button (Ctrl+A), and press F8 on the keyborad (Convert to Symbol) to convert it into a Button.
Step 4
Click on File > Import > Import to Library, and choose c:disk > Windows > Media > notify, to import a sound into a flash Library.
Step 5
If you now open the Library (Ctrl+L),
Step 6
Double click on the button or choose right click and Edit in Place.
Step 7
Double click on layer1 to rename its name into a graphic. Insert a new layer and name it sound.
15. Step 8
Lock graphic layer, click on the sound layer and under Down
choose right click > Insert Keyframe.
Step 9
Then, using a drag and drop technique, move your sound (notify)
from Library on the stage.
Step 10
Unlock the graphic layer, and under Hit, choose right click > Insert
Keyframe.
Go back on the main scene (Scene 1), open the Properties Panel
(Ctrl+F3) and set the options
16. Do this
Step 1
Create a new Flash Document, click on file > Import > Import to Library and choose C:disk > Windows > Media > Windows XP
Startup, to import a sound into a flash Library.
Step 2
Draw a "play" and "stop" buttons on the stage.
Step 3
After that select it (Ctrl+A) and press F8 on the keyborad (Convert to Symbol) to convert it into a Movie Clip.
Step 4
Double click on a new made Movie Clip (stop and play buttons) or right click and choose Edit in Place.
Step 5
Select the "play" button, and press F8 on the keyboard to convert it into a button.
Step 6
Select the "stop" button, and convert it into a button in an equivalent way like we have converted the play button.
Step 7
Insert a new layer and name it sound. Then click on the first frame of layer sound and using drag and drop technique move
your sound (Windows XP Startup) from the Library on the stage.
17. Step 8
Click again on the first frame of layer sound, open the Properties Panel (Ctrl+F3), and under Repeat
option set some huge number.
Step 9
Insert a new layer and name it action.
Step 10
Take the Selection Tool (V),
Step 11
Click on the first frame of layer action, open the Action Script Panel (F9), and paste this script:
stop ();
Step 12
Select the second frame of layer action, and paste this script:
stopAllSounds();
18. Step 13
Click on the first frame of Layer1, select the "play" button, and press Ctrl+B on the keyboard (Break Apart).
Step 14
While you're still on the first frame of Layer1, select the "stop" button, open the Action Script Panel (F9) and paste this script:
on (release) {
nextFrame();
}
Step 15
Click on the second frame of Layer1, select the "stop" button and press Ctrl+B on the keyborad to break it, like we have done
for "play" button in step 13.
Step 16
While you're still on the second frame of Layer1 select the "play" button, open the Action Script Panel (F9) and paste this script:
on (release) {
prevFrame();
}