FireworksColdFusionDreamweaverFreehandFlashMXHome
Latest New Content

Latest Free Content
View All
Free Content
Accessibility
CMX Learning Guides
Hosted by enterhost

Using Audio in Flash CS4

By: Tom Green , David Stiller ,

Page 1 of 3

Set for printing

Next

As Tom Green mentioned in his end-of-2008 video "A Quick Tour of the Flash CS4 Interface," the latest version of Flash introduces a handful of eye-popping new tools. These are covered in detail in our latest collaborative effort, Foundation Flash CS4 for Designers (ISBN: 1430210931, by Tom Green and David Stiller, published by friends of ED). We've taken an introductory look at some of these new features already in this series — and there's more to come — but it may encourage you in the meanwhile to hear that certain workflows haven't really changed much in Flash CS4, even though the user interface was overhauled completely.

One of these workflows pertains to timeline-based audio. In this excerpt, we'll take a look at the two basic types of sound in Flash: event and streaming. In a sense, it doesn't matter what version of Flash you're working with, these principles apply across the board — and amazingly, they haven't been covered before in a Community MX article, so let's jump in!

Choosing a Sound Type: Event or Streaming

Timeline sound is heard when a timeline's playhead passes over a frame that is associated with a sound asset. Flash has two types of sound: event and streaming. Event sound tells Flash to load a sound completely into memory — as soon as the playhead encounters the frame that contains the audio — before playing it. Once loaded, the sound continues to play, even if the movie's playhead stops, which means event sounds are not locked to the timeline. (Audio can be forced to stop, but that takes specific action on your part.)

In a 24 frames-per-second (fps) Flash movie, an audio file of three minutes' duration takes over 4,000 frames to play out completely. If you're hoping to synchronize that with animation in the same timeline, think again. If the resultant SWF is played back on a slower machine than yours, it's almost certain the audio will not conclude on the frame you expect. Also, a movie would take a long time to start playing, because Flash must load the sound fully before playback can begin. For this reason, Event sound is ideal for pops, clicks, and other very short sounds or in situations where the audio will be played more than once or looped. If you want to synchronize extended audio with timeline animation, use streaming sound.

Streaming sound is a sound that can begin playing before it has fully loaded into memory. The trade-off is that it must be reloaded every time you want to play it. This sound type is ideal for longer background soundtracks that play only once. Because it is locked in step with the timeline, streaming sound is the only realistic option for cartoon lip-synching, or any scenario that requires tight integration between audio and visuals.

Now that you know what to expect, let's work with both types.

  1. Open the Frog.fla file included with the sample files that accompany this article. You will see we have included a Frog.mp3 audio file in the library.
  2. Rename the layer in the timeline to "audio", and drag the Frog.mp3 file from the library onto the stage. Audio files can be added to the timeline by dropping them on the stage, where they seemingly vanish — but not by dragging them to the timeline. When you release the mouse, you may see a line running through the middle of frame 1 in the timeline. This line is the start of the waveform, but not the whole thing.
  3. Insert a frame at frame 15 of the timeline. You can now see the entire waveform (it takes approximately 15 frames' worth of time to play through).
  4. Right-click (Ctrl-click) on the layer name and select Properties from the context menu. In the Layer Properties dialog box, select 300% from the Layer height drop-down menu, as shown in Figure 1, and then click OK. When you release the mouse, the layer view is three times larger, and you can see the waveform in greater detail.


    Figure 1 Use the layer properties to 'zoom in" on the timeline

    Being able to see the waveform on the timeline is a huge advantage, because you can now use the waveform's peaks or valleys to time animation or other events to the audio file in stream mode.

  5. Click in the waveform on the timeline anywhere but frame 1. In the Sync area of the Property inspector, select Event from the drop-down menu and press Enter (Return). The playhead moves, but the sound doesn't play. Drag the playhead to frame 1 and press Enter (Return) again.

    What you have just heard is a fundamental truth of an event sound: you can preview event sounds only by playing them in their entirety, and only from the keyframe in which they appear.

Page 1 of 3 1 2 3 Next


download
Download Support Files


Keywords
Flash CS4, audio, event, stream