Incorporating audio can really bring life to a Flash movie; however, the effect is very subtle. For example, most people would not be able to tell you the background music playing behind their favorite movie, but try leaving the sound out and they’ll immediately notice. This makes audio a powerful influence on the viewers of your Flash movies. Adobe understands the power of audio and gives you the ability to import audio in a variety of formats, including ASND, MP3, WAV, AIF, and AU. If you want more control over your audio, you can edit sounds in Adobe Soundbooth CS4 directly from Flash (New!). You can use on-clip controls to make fast edits and intuitive, task-based tools to clean up recordings, polish voice-overs, customize music, modify sound effects, apply high-quality filters, and much more.
There are two types of sounds: event sounds and stream sounds. An event sound needs to download completely before it starts to play, while a stream sound starts to play as soon as enough data downloads for the first few frames. Event sounds continue to play until they are done or you explicitly stop them. Steam sounds are synchronized to the Timeline for playing on a web site.
Flash audio can be controlled using Flash’s version of JavaScript, called ActionScript, and it even gives you the ability to load streaming MP3 files. Add to that the ability to choose between mono and stereo, and you can further reduce the size of your audio files (mono audio files are half the size of stereo). The one drawback to using audio is that it produces a much larger file (even compressed audio files are relatively large), but even this can be reduced to a minimum by using shared audio libraries. Since audio files create large Flash movies, use sounds when they are necessary to the design of the Flash movie, and remember that sometimes silence is golden.
When working with Flash, understand that Flash will let you import audio in a variety of formats. However, Flash has no way to record or create sounds; you can do it with Adobe Soundbooth. Therefore, audio must come from external sources. You can use the sample Sounds library that comes with Flash (New!) or conduct audio searches on the Internet using your favorite search engine to find a lot of audio files. One other consideration is creating your own audio, using your computer, an attached microphone, and a bit of imagination. Flash supports the following sound formats: ASND (from Adobe Soundbooth) (New!), WAV, AIFF, MP3, Sound Designer II (Mac), Sound Only QuickTime Movies, AU, and System 7 Sounds (Mac). When you import an audio file to Flash’s Stage, you will first need to have a specific layer and keyframe selected. When you work on a Flash project, it might be beneficial to bring audio files directly into Flash’s Library. That way you have easy access to them when needed. Any unused audio files are purged when you publish the Flash movie.
Select a keyframe in the Timeline in which you want the audio file placed.
You should always place audio files in a separate layer. This gives you easy access and control over the audio file once it’s been placed on the Stage.
Click the File menu, point to Import, and then click Import To Stage.
Navigate to the drive or folder location with the files you want.
Select one or more audio files to import.
To select more than one file, click an audio file, then hold down the Shift key and click another file to select contiguous audio files, or hold down the (Mac) or the Ctrl key (Win), and then click to select non-contiguous audio files.
Click Import (Mac) or Open (Win).
Open and select the library where you want to import your audio files.
Click the File menu, point to Import, and then click Import To Library.
Navigate to the drive or folder location with the files you want.
Select the audio file or files you want moved into the Library.
Click Import To Library (Mac) or Open (Win).
You can sync sound to a Timeline animation. Select the sound on the Stage, and then change the Sync option on the Properties panel to Stream. Flash will force the animation to sync to the timing of the audio file even if it has to drop video frames to keep up.
See “Using Audio on the Timeline” on page 306-307 for information on importing audio using an external library.
Once you’ve imported audio files into the active document’s Library, it’s a simple matter to transfer the file to the Timeline. Flash’s Timeline is actually a frame-by-frame representation of the Stage. For example, if you select frame 23 on the Timeline, the Stage displays the contents of the 23rd frame on the Stage. Audio, however, does not have a visible Stage object, so when you add an audio file to the Timeline, the effects are only apparent on the Timeline, not the Stage. Flash’s Library holds all of the audio files that you’ve imported into the active Flash document. No matter how many times you use that audio file in the source document, Flash only needs to save it one time in the published Flash movie. In addition the main Library, you can also use audio from the Sounds library that comes built-in to Flash (New!). One of Flash’s powerful features is the ability to use audio files from other Flash libraries. External Flash libraries are simply Flash source documents, which have an active Library. This gives you the ability to create libraries of audio files and use them over and over again.
Open the library that you want to use:
• Library. Click the Window menu, and then click Library.
• Sound Library. Click the Window menu, point to Common Libraries, and then click Sounds.
Select a layer and keyframe in the Timeline in which you want the audio file placed.
Drag the audio file from the Library directly onto the Stage.
Flash places the audio file in the selected keyframe.
Click the File menu, point to Import, and then click Open External Library.
Navigate to the drive or folder location with the files you want.
Select a Flash document that contains an active Library.
Click Open.
Drag items from the external Library directly to the Stage.
Drag items from the external Library to the active document’s Library.
When you drag an object from an external Library onto the Stage of the active Flash document, it is automatically added to the active document’s Library.
You can use a single Library panel for all open documents. When you open multiple documents, Flash now consolidates all the libraries into a single Library panel. Click the popup button (located at the top of the Library panel) to select from any available library.
See “Working with the Library Panel” on page 136 for information on using the single library panel and other options.
By default, Flash embeds audio files directly into the published (.swf) file. You have the option of loading audio files from a common Library. This gives you the advantage of using the same sounds in several Flash movies at the same time. For example, you create a Web site using fifteen separate Flash movie files, and each one uses the same background music. Rather than embed the same sound fifteen times, you can simply load the sound, when needed, from a common Library. Shared libraries are simple Flash documents that are set up to share their files between several Flash movies. The process is easy, and the rewards are great, and you don’t increase the file size of Flash movies using shared Library elements. Once you’ve created and defined a Flash document as a shared Library, you can use the items in other Flash movies without increasing the size of the Flash published .swf file.
Create a new Flash document.
Add the audio files to the document’s Library. They do not have to be placed on the Stage.
Click the File menu, and then click Save. Use a distinctive name for the source document.
Select an audio file in the Library.
Click the Library Options button, and then click Linkage.
Select the Export For Runtime Sharing check box.
a. If the check box is not available, clear the Import for runtime sharing check box.
Enter a distinctive name for the Identifier field or use the default.
Enter the name of the published document into the URL field.
Click OK.
Repeat steps 4 through 9 until all the audio files are correctly linked.
Click the File menu, and then click Publish to create the Flash .swf file.
Close the original source file.
Click the File menu, point to Import, and then click Open External Library.
Select the shared Library, and then click Open.
The items in the external Library will be grayed out, indicated they are sharable items.
Drag the audio files from the external Library to the Library of the active document.
To display or change link properties for an audio, double-click the audio icon in the Library, click Advanced (if necessary), view or change link options, and then click OK.
When you publish the Flash .swf file, the audio files will be drawn from the common Library, without increasing the size of the Flash movie.
A Flash Library can be shared with other designers. Since a Library is simply a Flash movie with Library elements, you can create common libraries of often-used elements, and then give them to other designers. When you’re working with two or more designers, this is a great way to maintain consistency on a complex project.
Sound is a great motivator. For example, a particular piece of music can make you happy, or it can make you sad. In addition, sounds can pull out childhood memories and stir emotions. Sound is a powerful tool, however, different people react differently to sounds, therefore it’s important that you think carefully about the sounds you add to your movies. It’s equally important to understand how you can control your movies using using ActionScript 3.0 code or ActionScript Behaviors in ActionScript 2.0.
Create or open a Flash document (ActionScript 3.0).
Click the Window menu, click Library to open the Library panel, and then select an audio file from the available Library items.
Right-click (Win) or Command-click (Mac) the audio sound, and then click Properties. Click Advanced, if necessary.
Enter a distinctive name for the Identifier field or use the default.
Select the Export For ActionScript check box.
Leave the other fields at their default values, and then click OK.
Click Frame 1 in a layer.
Click the Window menu, and then click Actions.
Type the ActionScript code shown in the illustration:
Click the Control menu, and then click Test Movie to test the ActionScript.
Create or open a Flash document (ActionScript 2.0).
Click the Window menu, click Library to open the Library panel, and then select an audio file from the available Library items.
Click the Library Options button, and then click Properties. Click Advanced, if necessary.
Select the Export For ActionScript check box.
Enter a distinctive name for the Identifier field or use the default.
Leave the other fields at their default values, and then click OK.
Click the Window menu, and then click Behaviors to open the Behaviors panel.
Select a button object on the Stage or Timeline keyframe.
Click the plus (+) sign, located in the upper-left portion of the Behaviors panel, point to Sound, and then click Load Sound From Library.
Enter the name of the audio file in the Linkage ID field.
Enter a unique name in the instance field.
Select the Play This Sound When Loaded check box.
Click OK.
Select an Event to trigger the sound. If the audio file was added to a Timeline frame, the event field will be disabled.
Click the Control menu, and then click Test Movie to test the ActionScript.
Whenever you place sounds in a Flash document, it’s nice to give your visitors control over the playing and stopping of a specific sound. Giving visitors control over a Flash movie gives them more confidence. Most marketing studies show that if a visitor has more confidence over a Flash document, they’ll stay longer. If it’s a marketing document, that confidence translates into a greater chance that the visitor will buy what you’re selling. If it’s a training document, the visitor is more likely to listen to what you’re saying, and learn from it. Remember, control leads to confidence, and to better Flash documents.
Create or open a Flash document (ActionScript 2.0), and then select a sound in the Library.
Click the Library Options button, and then click Properties. Click Advanced, if necessary.
Select the Export For ActionScript check box, and then click OK.
Select a layer to place the sound.
Click the plus (+) sign located in the upper-left portion of the Behaviors panel, point to Sound, and then click Load Sound From Library.
Enter the name of the sound in the Linkage ID field.
Give the file a unique instance name.
Clear the Play This Sound When Loaded check box.
Click OK.
See Project 6, “Creating a Context Menu” on page 521 for ActionScript code to play and stop an animation.
Place a Play and Stop button on the Stage.
Click the Play button.
Click the plus (+) sign, located in the upper-left portion of the Behaviors panel, point to Sound, and then click Play Sound.
Enter the name of the sound instance to play.
Click OK.
Select an Event to play the sound.
Click the Stop button.
Click the plus (+) sign, located in the upper-left portion of the Behaviors panel, point to Sound, and then click Stop Sound.
Enter the name of the sound instance to stop.
Click OK.
Select an Event to stop the sound.
Click the Control menu, and then click Test Movie to test the ActionScript.
You can load an MP3 music audio file using a built-in Flash behavior. The advantage to this process is that the file is loaded when needed, and it never increases the size of the original Flash movie. Flash performs a calculation on audio files as they are loading. When it has enough of an audio file, it begins playing, while it continues to download the remaining information in the background. For large audio files, this cuts down on long wait times and keeps the visitor from becoming bored. Streaming MP3 files are not part of a pre-existing Flash movie, they’re just available from a common location.
Create or open a Flash document (ActionScript 3.0), and then select a button object on the Stage.
Open the Properties panel.
Enter a distinctive name for the object in the Instance field, such as myButton.
Click Frame 1 in the actions layer.
Click the Window menu, and then click Actions.
Enter the script as shown in the illustration:
Click the Control menu, and then click Test Movie to test the ActionScript.
See Project 2, “Loading and Formatting Text” on page 511 for ActionScript 3.0 code to load external text.
Create or open a Flash document (ActionScript 2.0), and then select a button object on the Stage or Timeline keyframe.
Click the plus (+) sign, located in the upper-left portion of the Behaviors panel, point to Sound, and then click Load Streaming MP3 File.
Enter the URL to the source MP3 file.
Enter a unique name in the identifier field.
Click OK.
If you selected a button object, select an Event to trigger the sound.
Click the Control menu, and then click Test Movie to test the ActionScript.
You can stop all sounds using an ActionScript Behavior. Create or open a Flash document (ActionScript 2.0) that contains playing audio files, place a button object on the Stage, and then select it. Click the plus (+) sign in the Behaviors panel, point to Sound, and then click Stop All Sounds. Click OK. Select an Event to stop the sound.
When you sync a sound to the Timeline, you’re essentially instructing Flash how to play the sound. Syncing sounds is a fundamental operation because choosing the wrong sync operation can drastically change how the sound plays out during the execution of the Flash movie. Flash gives you the ability to choose a separate sync operation for each individual sound file. When you place the sound on the Timeline, the Properties panel displays the audio properties for the selected sound and lets you define individual properties for every sound in your Flash document. For example, you have a background music sound that’s located in several scenes, and you want to make sure it doesn’t play on top of itself (Sync: Stop). Or, you have a narration that you want perfectly synced to an animation on the Timeline (Sync: Stream).
Select the keyframe on the Timeline containing the sound you want to sync.
Click the Window menu, and then click Properties to open the Property Inspector.
Click the Sync popup, and then select from the following options:
• Event. When you select Event (default) the sound plays when the record head reaches the keyframe containing the sound, and continues to play until the end of the sound. If the record head reaches another keyframe that contains the same sound, it will begin playing on top of the original sound.
• Start. Doesn’t allow the sound to play on top of itself.
• Stop. Stops a sound if it is already playing, without affecting any other sounds.
• Stream. The Stream Sync creates sounds synchronized to the Timeline. This is useful for matching sounds to a particular visual event in the movie. If the video can not keep up with the audio, Flash will automatically drop video frames to keep the audio synchronized.
Once a sound is imported into Flash and placed on the Timeline, you can add sound effects and determine the number of loops. When you loop a sound, you’re instructing the Flash movie to repeat the sound a given number or times, or to loop the sound forever. Some sounds loop better than others. For example, you create some background music, and you want it to continue to play for as long as the visitor is on that particular page, but you don’t want the sound to have a definable beginning or end. In addition to loops, you can also add effects to a sound, including fades in and out, and fade to the left or right channel. The effects applied will only modify the selected audio file. Each copy of an audio file dragged into a Flash movie is controlled independently.
Select the keyframe on the Timeline containing the sound you want to change.
Click the Window menu, and then click Properties to open the Property Inspector.
To add effects to the sound, click the Effect popup, and then select an option:
• Left Channel/Right Channel. Plays sound in the left or right channel.
• Fade Left To Right/Fade Right To Left. Changes sounds from one channel to the other.
• Fade In. Increases volume.
• Fade Out. Decreases volume.
• Custom. Creates custom in and out sound points using the Edit Envelope.
To loop a sound, click the popup, and then select an option:
• Loop. Click Loop to force the sound into an infinite loop.
• Repeat. Click Repeat, and then enter the number of times you want the sound to loop (up to 65,535).
Sooner or later, you’re going to want to export your Flash movie that contains audio as an SWF file. The process of publishing is relatively painless; however, there are a few considerations as to the compression of the files, which will be important to the size and playability of the Flash movie. Publishing requires knowledge of where the document will be used. For example, if the document is to be streamed over the Internet, and your visitors have relatively low bandwidth, you would want to choose compression settings that would significantly reduce the size of the audio files. It’s possible that the Flash document is intended for playing off a CD/DVD; in that case, you could increase the compression settings. When you’re designing a Flash document, it’s imperative that you understand the end game and design the document toward that goal. Always remember that you can design a Flash document, but it’s your visitors that ultimately will see, and use it.
Click the File menu, and then click Publish Settings.
Click the Formats tab, and then select the Flash (.swf) check box.
Click the Flash tab.
Click the Set buttons for Audio Stream or Audio Event.
Select other sound options as desired:
a. Select the Override Sound Settings check box to override any sound settings applied to the individual sound files within the active Flash document.
b. Select the Export Device Sounds check box to export sounds suitable for devices, such as mobile devices, instead of the library sound.
Click the Compression popup, and then select from the following options:
• Disable. Turns off all sound compression options and instructs Flash not to export sounds.
• ADPCM. Performs minor compression to the audio files.
• MP3. Creates audio files, especially music files, with excellent quality in a small file size.
• Raw. Leaves the sounds intact without any compression schemes applied.
• Speech. Creates optimized files for the human voice.
Select the Convert Stereo To Mono check box for the ADPCM and RAW compression formats.
Based on your Compression selections from step 5, select the following options:
• Sample Rate. Available for ADPCM, Raw, and Speech compression. The higher the sample rate the better the quality, but the bigger the file.
• ADPCM bits. Higher bit values translate into better quality audio, but larger file sizes.
• Quality. Available for MP3 compression. The Best option gives the finest quality, but produces a larger file.
• Bit Rate. Available for MP3 compression. The higher the value, the better the quality and the bigger the file.
Click OK.
Select the Override Sound Settings check box to take priority over the individual settings applied to the audio files.
Select the Export Device Sounds check box to export device sounds with the published Flash movie.
Click OK.
Flash is not a major sound editing application. For example, you can’t trim or cut audio files, nor can you enhance audio or reduce hum and background noises. Flash expects all that to be done before you import the file. However, you do have some control over when the sound begins and ends (time in, and time out), and you do have control over the volume (fade in and fade out). Making sure that your audio file is clean and smooth flowing will help with the quality of your audio file.
Select a keyframe on the Timeline that contains an audio file.
Click the Window menu, and then click Properties to open the Property Inspector.
Click the Edit button.
Click the Effect popup, and then select a channel, fade, or custom effect.
Drag the Time In marker to the right to change where the audio file begins.
Drag the Time Out marker to the left to change where the audio file ends (the Time Out marker appears at the end of the audio file).
Click the Envelope lines to adjust the volume on the right or left channels.
Use the Zoom buttons to increase or decrease the size of the audio file in the edit window.
Click the Play or Stop buttons to test the changes to the audio file.
Click the Time Marker buttons to change the marker code from frames to seconds.
Click OK to save your changes.
Adobe Soundbooth is a program that allows you to record and modify sound files. If you have Soundbooth CS4 installed on your computer, you can edit imported sounds in Soundbooth directly from within Flash (New!). When you’re done editing the sound file in Soundbooth, you can save the file and your changes automatically appear in Flash. If you change the name or format of a sound after editing it, you’ll need to re-import the modified file back into Flash. You can edit all different sound file formats in Soundbooth. If you want to non-destructively edit sounds, then use the default sound file format (ASND) in Soundbooth for the best results.
Click the Window menu, and then click Library to open the Library panel.
Right-click (Win) or Control-click (Mac) the sound file you want to edit, and then click Edit with Soundbooth.
The sound file opens in Adobe Soundbooth.
Edit the sound file using Sound-booth tools and commands.
a. Use Help in Soundbooth to edit the sound file the way you want.
When you’re done, save the sound file in Soundbooth. Click the File menu, and then click Save.
• To save the changes in a non-destructive format, save the file using the ASND file format, the default in Soundbooth.
• If you change the name or format of a sound after editing it, you’ll need to re-import the modified file back into Flash.
Quit (Mac) or exit (Win) Soundbooth to return to Flash and view the edited version of the sound file in the Library panel.