Importing Sounds into Flash


In the preceding section, we discussed the various sound formats that Flash 8 can import and export. In addition to covering the merits of the MP3 and Speech codecs, we also explained the uses of platform-specific AIF (Mac) and WAV (Windows) audio files. But we didn't delve into the process of importing sound into Flash 8. So, let's get started.

Note 

When working with sound, you may encounter some interchangeable terminology. Generally, these terms — sound file, sound clip, and audio file — all refer to the same thing, a single digital file in one of several formats, which contains a digitally encoded sound.

Unlike other imported assets, such as bitmaps or vector art, Flash won't automatically insert an imported sound file into the frames of the active layer on the timeline. In fact, you don't have to select a specific layer or frame before you import a sound file. That's because all sounds are sent directly to the Library immediately upon import, regardless of whether you use File ð Import ð Import to Stage or Import to Library. After import, the sound becomes part of the Flash document file (.fla), which may make the file size balloon significantly if the sound file is large. The sound does not become part of the Flash movie file (.swf), nor will it add to the size of the Flash movie unless it is assigned to a keyframe, as an instance of that sound, or it is set to export for use in ActionScript.

Tip 

Flash Players 6 and higher allow a Flash movie to load MP3 files directly. Earlier versions of the Flash Player required Macromedia Generator (or an equivalent server-side application) to transform sound files into Flash movie files (.swf) on the fly. We'll show you how to load and attach sounds with ActionScript in Chapter 28, "Sharing and Loading Assets."

To import a sound file into the Flash 8 authoring environment, follow these steps:

  1. Choose File ð Import ð Import to Library or Import to Stage (Ctrl+R or z+R). For sound assets, these commands work identically.

  2. From the Files of type list (Windows) or Show list (Mac) in the Import dialog box, select All Sound Formats.

    Caution 

    On the Mac OS X version of Flash 8, you may need to choose All Files in the Show menu in order to select an appropriate sound file.

  3. Browse to the sound file that you want to import.

    On the CD-ROM 

    If you're looking for a sample audio file, you can import the atmospheres_1.mp3 file found in the ch15 folder of this book's CD-ROM.

  4. Click Open.

    The sound file you select is imported into your Flash document file (.fla) and arrives in the document's library with its filename intact. If the Library panel is closed, you can open it by choosing Window ð Library, or by using the keyboard shortcut (Ctrl+L or z+L). With the Library panel open, locate the sound, and click it to highlight the name of the sound file where it appears in the Library list. The waveform appears in the Library preview pane, as shown in Figure 15-1. Click the Play button above the waveform to audition the sound.

image from book
Figure 15-1: This is a stereo sound in the Flash document's library.

Cross-Reference 

Refer to the "Fine-Tuning Sound Settings in the Library" section, later in this chapter, for an explanation of how you can specify unique compression settings for each sound in a document's library.

You may also load sounds from a shared library. Refer to Chapter 28, "Sharing and Loading Assets," to learn more about shared libraries. Chapter 28 also shows you how to preload an MP3 file into a Flash movie file (.swf). To learn how to assign a linkage identifier string to an asset, such as a sound file, refer to Chapter 27, "Interacting with Movie Clips."

You can also import sound files into a Flash document by dragging the sound file from the desktop to the Library panel. On the Macintosh, you can drag the sound file to the Stage as well. This method can be especially useful when you have searched for a sound file using the operating system's search tool (Start ð Search in Windows, or Sherlock in the Mac OS), and want to quickly bring the sound file into Flash 8.

image from book
How Sound Is Stored in a Flash Movie

Earlier in this chapter, we mentioned that when you import a sound file into a Flash document file (.fla), an entire copy of the sound file is stored within the document. However, when you place a sound on a timeline, a reference is made to the sound in the library. Just as symbol instances refer to a master or parent symbol in the Library, sound "instances" refer to the master sound resource in the Library.

Throughout this chapter, we use the term "instance" for sound assets with this understanding in mind. When the Flash document is published as a Flash movie, the master sound in the Library is compressed and stored once in the final movie file (.swf), even though there may be several instances of that sound used through the movie (for example, in multiple frames on multiple timelines).

This type of efficient storage, however, applies to Event sounds only. Whenever you use Stream sounds, the sound file is stored in the Flash movie each time you refer to the sound in a Timeline. For example, if you compressed a sound to export from Flash as a 3K sound asset in the final movie file (.swf), you could reuse that sound as an Event sound several times without adding significant bytes to the file size. However, that same compressed sound (at 3K) would occupy 12K in the final movie if it was placed four times as a Stream sound on keyframes within the movie. We'll discuss Event and Stream sounds later in this chapter, so you may want to refer to this sidebar at a later point.

It is also worth mentioning that Flash 8 must have enough available RAM on the computer system to accommodate imported sound files. For example, if you import a 30MB WAV file into a Flash document, then you must have an additional 30MB of RAM available to the application. On 32-bit Windows operating systems and Mac OS X, you will not likely experience problems with memory usage, where virtual memory exists alongside the physical RAM within the computer.

image from book




Macromedia Flash 8 Bible
Macromedia Flash8 Bible
ISBN: 0471746762
EAN: 2147483647
Year: 2006
Pages: 395

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