Recipe 17.3. Adding a Sound to a Timeline for Playback


Problem

You want to add an imported sound to your movie's timeline.

Solution

Create a new layer within the timeline into which you want to add the sound, create a new keyframe if necessary, and with the keyframe selected, drag the sound from the library onto the stage.

Alternatively, instead of dragging the instance from the library onto the stage, you can select the keyframe, and select the sound you want to add from the Sound menu in the Property inspector.

Discussion

Obviously, before you can add a sound to a timeline for playback, you need to import the sound into the movie. See Recipe 17.1 for more information on that process. After you have imported a sound, you can add it to any keyframe by selecting that keyframe and then dragging the sound symbol from the library and dropping it on the stage. It is a good practice to always create a new layer for each sound in your timeline. Here is the step-by-step process for adding an imported sound to the movie:

  1. Create a new layer in your timeline to which you want to add the sound.

  2. Name the layer with a name that describes the sound you are adding to it. For example, if the sound is a narration, you could name the layer Narration Sound.

  3. If you want the sound to start on a frame other than the first frame, add a keyframe at the frame from which you want the sound to start playback.

  4. Select the keyframe to which you want to add the sound.

  5. Open the library, and drag an instance of the sound symbol onto the keyframe in the timeline. If you do this successfully, the sound will be added to the corresponding keyframe. If you have enough blank frames after the keyframe, you should see the sound's waveform appear within the timeline on that keyframe. If you don't have enough blank frames after the keyframe, you can still verify that the sound was added by checking the Sound menu in the Property inspector for that keyframe.

As an alternative to dragging and dropping the sound onto the stage, you can also choose the sound you want to add to a keyframe from the Sound menu in the Property inspector. To do this, follow steps 1 through 4 from the preceding list, and then in the Property inspector choose the sound you want to add from the Sound menu.

When you add a sound to a keyframe, the synchronization defaults to Event. You can also select from other types of synchronization options if Event does not meet your movie's needs. Synchronization can affect how the sound plays back as well as how the Flash movie plays, and it is an important topic. See Recipe 17.4 and Recipe 17.10 for more information on how to synchronize your sounds.

See Also

Recipe 17.4 and Recipe 17.10 for more information on how to synchronize sounds. Also, see Recipe 17.5 for more information on how to place a sound in a button timeline so that the playback occurs when the user clicks on the button.




Flash 8 Cookbook
Flash 8 Cookbook (Cookbooks (OReilly))
ISBN: 0596102402
EAN: 2147483647
Year: 2007
Pages: 336
Authors: Joey Lott

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net