Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 30 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
30
Dung lượng
1,04 MB
Nội dung
ptg Importing Sounds 231 Rights Management (DRM) technology that make them difficult or impos- sible to copy. Some CDs don’t even play in your CD player. Fortunately, you can usually use sound in your animation without worry- ing about all these details, as you see in the next task. Import a Sound TRY IT YOURSELF ▼ The process of importing sounds into Flash is simple. Follow these steps: 1. In a new file, select File, Import, Import to Library, and then select an audio file to import. In Windows, you are likely to find a few WAV files in the folder C:\Windows\Media or My Documents\My Music, or you can search for *.wav and *.mp3; Macintosh (Mac) users can use Find for Files of Type: Sound. You can filter the files shown in the Import di- alog box by setting the Files of Type drop-down list to All Sound For- mats, as shown in Figure 13.1. If you simply can’t find any audio files, you can download some from the publisher’s website. FIGURE 13.1 When importing audio or any me- dia type, you can filter the types of files listed to include only the formats you are seeking. 2. After you select an audio file and click OK in the Import dialog box, you don’t see anything on the Stage or Timeline. However, the sound has been imported and now resides in the Library. Open the Library window by pressing Ctrl+L to see it. Now that the movie contains the sound file, you can use the sound. 3. Although we’re not covering how to use sounds in depth until the next section, it’s easy. There are two basic ways to use the sound in a From the Library of Lee Bogdanoff ptg 232 HOUR 13: Including Sound in Animations Using Sounds Now that you’ve imported sounds into a movie, you need to make them play at the correct time. Without using ActionScript, the one place you can use sounds inFlash is in keyframes. With ActionScript, you can add sounds dynamically by using the Sound object, for which we provide the starter code after this hour’s “Summary” section. If you want a sound to play whenever the user places his or her cursor over a button, you still need to place the sound in a keyframe; it’s just a keyframe in the button. (Never fear, we get to buttons in Hour 16, “Basic Interactivity.”) TRY IT YOURSELF ▼ Import a Sound keyframe. One way is to drag the sound from the Library window onto the Stage. This method requires an editable frame, which is located in an unlocked layer marked as editable with a pencil and with the cur- rent-frame marker in a non-tweened frame. The other method requires you to select a keyframe by clicking under 1 in the Timeline, and then in the Properties panel, select the sound you imported from the drop- down list, as shown in Figure 13.2. This list displays all the sounds previously imported into the movie. In our example, we import a sound named Ooooh.wav. 4. Test the movie, and you should hear the sound. Of course, your com- puter speakers and sound card must be functioning. FIGURE 13.2 When a keyframe is selected, the imported sound appears in both the Library and the Properties panel. From the Library of Lee Bogdanoff ptg Using Sounds 233 Knowing that sounds go in keyframes is fine, but you need a way to put them there. When you select a keyframe, the Properties panel provides a way to control what sounds play when you reach the selected keyframe. Flash provides other clues for you to see where sounds have been placed. For example, if your Timeline is long enough, you see a waveform or a vi- sual representation of a sound for the sound being used, as shown in Figure 13.3. FIGURE 13.3 The waveform is displayed in the Timeline. This is helpful when you’re trying to synchronize images with specific parts of sound. Using the Properties panel is the best way to see which sounds have been added to which keyframes. Like any other panel, the Properties panel dis- plays only the sound used in the selected keyframe. Misreading this panel is easy because it changes when you deselect keyframes. Figure 13.4 looks al- most identical to Figure 13.3. However, in Figure 13.4, the Properties panel shows no sound is being used. When you look closely at the Timeline, you see a waveform is displayed, but no keyframe is selected. Therefore, it’s necessary to look at the Properties panel after you’ve selected a particular keyframe. Sync Settings When you have the Properties panel reflecting sound for the intended keyframe, you can decide exactly how the sound should play. The most fundamental choice you need to make is the Sync setting. This controls ex- actly how a particular instance of the sound plays or, more specifically, the priority of the sound compared to the visual elements in the animation. Be- From the Library of Lee Bogdanoff ptg 234 HOUR 13: Including Sound in Animations fore you try out the Sync settings, see the following list and Figure 13.5 for an explanation of each: . Event—This setting should be your default choice, especially for sound effects and other incidental sounds. When Event is chosen, sounds start to play when the keyframe is reached and keep playing until the sound is done. Event sounds might not coincide with visual elements the same way on everyone’s machine. Sounds don’t play FIGURE 13.5 For each instance of a sound, you must select a Sync setting via the Properties panel. FIGURE 13.4 The Properties panel can be con- fusing; it only displays or enables you to specify sounds when a keyframe is currently selected. The keyframe isn’t currently selected, so the Properties panel displays nothing. From the Library of Lee Bogdanoff ptg Using Sounds 235 more slowly or quickly because that would make them sound odd, but a machine with slower graphics performance might take longer to display visual elements. Suppose you have a 1-second sound set to Event, and your frame rate is 12 fps. You would expect that during the sound, 12 frames would be displayed, but a slow machine might display only 6 fps during that 1 second. In either case, the sound fin- ishes 1 second later, as you would expect, but the number of frames displayed can vary. . Start—This setting is almost the same as Event, except that multiple instances of the same sound are prevented. With Event, a sound can be layered on top of itself, similar to singing a round. Start, on the other hand, plays a sound if it’s not already playing. . Stop—This setting is for when you want a specified sound to stop playing. Say you import a sound called Background Music, and make it start playing in the first keyframe of one layer. Then, you import another sound called Narration and make it start playing in the first keyframe of another layer. In Frame 10, you place another keyframe with the same sound (Background Music) set to Stop, so that sound stops. Both sounds start at the beginning, but on Frame 10 the back- ground music stops and the narration continues to play. This is a bit strange because normally you use the Properties panel to specify the sound you want to play where here you specify the sound you don’t want to play. Think of Stop as “Stop this sound if it’s playing.” . Stream—This setting causes the sound to remain perfectly synchro- nized with the Timeline. Because you can’t have sounds playing slowly if the user’s machine can’t draw frames quickly enough, this setting forces Flash to skip frames to keep up. Stream sounds start playing when the keyframe is reached and continue to play as long as space is available in the Timeline. In other words, if your sound is 3 seconds long and you’re playing at 12 fps, the Timeline has to be at least 36 frames; otherwise, part of the sound is never reached. You can compare the Stream setting to a Graphic Symbol’s behavior. The ben- efit of the Stream setting is the synchronization is always the same. If in this case you place a graphic in Frame 12, it coincides perfectly with the first second of your sound. Remember when you’re using Stream, you have to ensure enough frames are in the Timeline to ac- commodate the length of the sound. Finally, you preview Stream sounds as you scrub, thus making the process of synchronizing audio to images possible. The decision as to which Sync setting to use isn’t terribly difficult. Event should be used for any short incidental sounds, such as rollover sounds.We From the Library of Lee Bogdanoff ptg 236 HOUR 13: Including Sound in Animations suggest Event for all sounds that don’t require critical synchronization. Background music that plays and loops doesn’t need to be synchronized, so you should use Event for it. Start is a perfectly good alternative to Event because it’s the same, but it prevents the same sound from layering on it- self. For example, suppose you have a row of five buttons. If each button has the same rollover sound and the user quickly moves across all five, an Event sound plays once for each button. If the sounds are short enough, this is probably appropriate. However, if the sounds are quite long, they be- come discordant. If you use the Start Sync setting, only one instance of the sound plays at a time, regardless of how fast the user moves his or her mouse. Event can be a better choice than Start when a little bit of overlap is okay. Conversely, say you want to hear a smack sound effect every time a ball bounces on the ground. If you choose Event, you hear a smack for each bounce, even if the ball bounces a second time before the first sound finishes. In any event, Start and Event are good for the majority of sounds you play. The Stop Sync setting is powerful. It gives you a way to stop specific sounds. Using this method can be a tricky because it stops only one sound per keyframe. Depending on the situation, this might be appropriate. If you’re giving the user the ability to get several sounds at once, you want to learn about Stop All Sounds. Suppose you have one sound playing in the background, and when a tween starts, you want a special sound effect to play and keep playing until the tween ends. You can put the background sound in an early keyframe, and then in the first keyframe of the tween, place the sound effect and set its Sync setting to Event or Start. In the last frame of the tween, you can use the same sound effect but with the Stop Sync setting. This way, the sound effect stops at the end of the tween, but the background sound continues. Finally, Stream is good for one thing: synchronizing graphics with sound. This is especially useful for character animation where you want a charac- ter’s lips to synchronize with its voice. When trying to synchronize sounds with images, you can use the scrub technique; if you use Stream sounds, you can hear the sound as you scrub. Because Stream sounds effectively lock themselves to the Timeline, you probably don’t want to change the movie’s frame rate. For example, a 3-second sound takes 36 frames at 12 fps. If you do some work and then change the frame rate to 24 fps, the same 3-second sound spans 72 frames! Flash automatically spreads the Stream sound out so it takes 3 seconds when you change the frame rate, but Flash doesn’t change your graphics, which now plays in 1.5 seconds. See Figure 13.6 for a before-and-after example of changing the frame rate after an ani- mation is built. NOTE Rollover Sound Rollover is when the user places his or her cursor over a button, so a rollover sound is a sound that plays when the user rolls over a button. From the Library of Lee Bogdanoff ptg Using Sounds 237 In spite of this issue, you should stick with a frame rate. Stream sounds re- main pretty appealing. However, on slower-performing machines, frames are skipped to make sure a stream sound stays synchronized. It’s often more important that every frame of your animation appears even if it means the sounds might drift out of synchronization. Use Stream only when the synchronization is critical, and you don’t mind dropping frames. Otherwise, use Event or Start. Effect Settings The Properties panel provides some fancy effects you can apply to the vol- ume of a selected sound. The drop-down list next to Effect includes effects such as Fade In, Fade Out, Fade from Left to Right, and Fade from Right to Left. To understand and customize these settings further, you can either se- lect Custom from the list or click the Edit button on the Properties panel to access the Edit Envelope dialog box, which is shown in Figure 13.7. FIGURE 13.6 The same animation and sound are shown with frame rates of 18 fps (top) and 6 fps (bottom). Notice keyframes and tweening are not af- fected, but the sound uses less of the Timeline when the Timeline is advancing at 6 fps. The short si- lence at the start of this sound means users don’t hear anything until a few frames of the animation have played. Left channel Right channel Envelope lines Stop/Play Envelope handles Zoom in/out Display units Time in marker FIGURE 13.7 The Edit Envelope dialog enables you to modify the volume of the sound as it plays through the left and right channels. From the Library of Lee Bogdanoff ptg 238 HOUR 13: Including Sound in Animations Additional details for the Effect settings are . Left Channel/Right Channel—This option displays different wave forms if your original sound was stereo. If you use only mono sounds, you still get the left and right channels, so you can create panning effects. In the case of mono, the same sounds come out of each speaker, but you can modify the volume of each. . Envelope lines—These indicate the volume level at any particular time in the sound. When the line is at the top, the sound plays at full 100% volume. Some audio tools are different because they use the middle to indicate 100% and anything higher to indicate amplified or boosted sound, but this is not the case in Flash. As the envelope line is getting higher when you move to the right, the volume is increasing. . Envelope handles—These are like keyframes within sound. If you want the envelope lines, which indicate volume, to change direction, you need to insert a handle. All you need to do is click anywhere on a line, and a handle is inserted. No matter which channel you click, a matching handle is placed in the other channel. A handle in one channel must match the moment in time (left to right) of the handle in the other channel. However, the volume (height) can vary between the two. . Time In Marker—This marker enables you to establish the starting point of a sound. You’re effectively trimming the extra sound or si- lence at the beginning of the sound file. You’re not telling the sound to start any later, but the sound you hear begins wherever the Time In marker is placed. . Time Out Marker—This marker enables you to trim extra sound off the end of a sound file. Often, you have a moment of silence at the end of a sound file, and even if you don’t hear anything, it adds to the file size. You can get rid of it by moving the Time Out marker to the left. You don’t actually destroy the source sound in your Library, but when you export the movie, the unused portions of the sound isn’t used so your file stays small. . Stop/Play—This option enables you to preview all the settings you’ve made. This is important because although the waveform can enable you to visualize a sound, you ultimately want to judge the effect of a sound with your ears. . Zoom In/Out—This option enables you to zoom in for a close up of the current window to control precisely how you place the Time In/Out markers or envelope handles or zoom out so the entire sound fits in the current window. From the Library of Lee Bogdanoff ptg Using Sounds 239 . Display Units (Time or Frames)—This option simply changes the units displayed in the center portion from time units (seconds) to frame units. Time is not as useful as Frames when you want to match sound to a particular frame where something visual occurs. If the dis- play shows a peak in the music at 1 second, you have to use frame rate to calculate exactly which frame that translates to. With the dis- play set to Frames, Flash does the calculations for you. Panning is an effect that makes sound seem to move from left to right or right to left. It’s a trick in which the volume for one channel (left or right) is increased while the volume for the other channel is decreased. When com- bined with a graphic moving in the same direction, this technique can be ef- fective. Imagine, for example, a car moving across the screen at the same time the audio pans in the same direction. Despite the details in the Edit Envelope dialog box, you only have two ba- sic ways to use it: You can either use a preset effect or make your own. You can start with a preset, such as Fade In, and then make modifications to it, essentially making a custom effect based on a preset. Use the effects in any way you think appropriate. Listen to the effect after each change by clicking the Play button. Nothing you do here affects the master sound in your Li- brary. You can use the same sound several times throughout a movie with different effects in each instance. One of the most important things to remember is the Time In and Time Out markers can save file size. Only the sounds and portions of sounds actually used are exported when you publish a movie. Unused sounds in the Li- brary and portions trimmed from the beginning or end of a sound are not exported. Trimming a few seconds off the end of a sound can mean many seconds, or even minutes, of download time for your users. Also, changing the volume of a sound has no impact on file size, so setting the envelope lines to the lowest level makes no sense. Loop Settings The Properties panel has an option that enables you to specify how many times a sound repeats or to have the sound loop forever. Some sounds loop better than others. Basically, a sound that loops well ends the same way it starts. There’s an art to making sounds loop. Al- though importing a large song and using the Time In and Time Out mark- ers to establish a nice looping sound is possible, it isn’t easy. More likely, you have to find a sound already prepared by an audio engineer. A profes- From the Library of Lee Bogdanoff ptg 240 HOUR 13: Including Sound in Animations sionally prepared sound can loop so seamlessly that you can listen to it and not even notice it’s looping; it sounds like it’s endless. You get to explore looping sounds as well as other effects in the next task. TRY IT YOURSELF ▼ Add Sounds and Sound Effects to an Animation In this task, you add sounds to a sample movie. Follow these steps: 1. Download the file keyframing.fla from the publisher’s website. In Flash, open this file, and then press Enter to watch the animation. 2. Open the Library for the keyframing.fla file by selecting Window, Library (or press Ctrl+L). 3. Now these sounds are available to your file, but you need to put them into keyframes. First, you need to make a new layer to contain the sounds; select Insert, Timeline, Layer. Don’t worry if Flash puts the new layer under all the others because it doesn’t matter where it ap- pears. Name this layer Background Music by double-clicking on its name and typing the new name. 4. Select the first frame of the Background Music layer, and look at the Properties panel. From the Sound drop-down list, select Visor Hum Loop. To make this sound loop continuously, change the drop-down list from Repeat to Loop, as shown in Figure 13.8. FIGURE 13.8 Flash can loop a sound indefi- nitely with the Loop setting. TIP Testing Your Movie Instead of using the Test Movie command, you’ve tested this movie by clicking the Enter or Return key, and you can’t get the sound to stop! It’s driving you crazy. To stop the sound, choose Control, Mute Sounds. This stops the looping sound. Then, choose Control, Mute Sounds again to uncheck it, so you can test it the right way using Control, Test Movie. 5. Select Control, Test Movie. The sound loops nicely, and it adds a bit of drama to the movie. In the following steps, you add some incidental sound effects. 6. Select Insert, Timeline, Layer, and name the layer Sound Effects. You’re going to inser t a sound effect when the “CS4” is rotated to the From the Library of Lee Bogdanoff [...]... converting to a symbol does: It takes what’s selected (in this case, the Wheel instance) and puts it into the Library In step 1, you put a shape in the Library In this step, you took an instance of the Wheel and put it inside the Rotating Wheel symbol From the Library of Lee Bogdanoff Movie Clip Symbol Behavior 3 Go inside the master version of Rotating Wheel by double-clicking the instance onscreen In. .. another instance of Rotating Wheel by either copying and pasting the instance onscreen or by dragging another instance from the Library Position the two Rotating Wheel instances side-by-side, and then have some fun using the Brush tool to draw the car body When you are done, select everything on the Stage, and convert it to a Movie Clip symbol called Car 7 Insert a frame at Frame 30 in the main Timeline,... about in Hour 13, “Including Sound in Animations.” Movie Clip instances are independent of the Timeline where they’re used They always play all their frames and loop Think of a Movie Clip as marching to the beat of its own drummer A 10-frame Movie Clip doesn’t care if it’s placed in a 10-frame timeline, 100 frames, or just one frame It plays all its frames when it can, like Rotating Wheel used in creating... likely to notice In the end, it’s basically magic because you’re left with a small sound file that sounds almost as good as the original Back to the world of Flash, the easiest way to approach audio is to bring in an uncompressed audio file and enable Flash to apply MP3 compression upon publishing the swf That is, you can bring in a wav, and Flash internally converts it to an MP3 Flash s MP3 compression... should see Scene 1: Rotating Wheel Click on the Wheel to select the instance You should see Instance of: Wheel in the Properties panel (as shown in Figure 14.2) This means that Rotating Wheel contains an instance of Wheel 255 TRY IT YOURSELF ▼ Use a Movie Clip to Make a Rotating Wheel FIGURE 14.2 The Properties panel displays a selected symbol’s original name 4 While inside Rotating Wheel, we do a simple... and File Size 243 Export Settings All this theory is interesting, but how do you apply it to your sounds? You have two places inFlash where you can specify quality and compression settings: the Sound Properties dialog box and the Flash tab of the Publish Settings dialog box The Sound Properties dialog box affects settings that are unique to the individual sound, and the Publish Settings dialog box... this hour in “Addressable Movie Clip Instances,” and again in Hour 16, “Basic Interactivity.” For now, all you need to know is you can name Movie Clip instances individually in the Properties panel If the only difference was a few settings in the Properties panel, you could do exercises with Loop, Play Once, and Single Frame, and that would be the end of it However, Graphic symbols differ in another... stereo sound Summary Flash supports audio elegantly Including audio in a movie is a simple process of importing the sound and then deciding in which keyframe you want the audio to play Many options are available on how the audio plays—for example, whether it plays and finishes naturally using the Event Sync setting or whether you want it to lock itself to the Timeline so images remain synchronized no... OK This takes you inside the master version of Numbers 2 In Frame 1 of Numbers, use the Text tool and type 1 near the center of the screen Insert a keyframe in Frame 2, and change the onscreen number to 2 Continue inserting keyframes and changing the contents to match the frame number all the way to Frame 10 3 Return to the main scene, making sure you’re not still in Numbers Drag an instance of Numbers... Remember, using Test Movie is the only way to see Movie Clip animation All 10 numbers appear in sequence, even though you used only one frame of the main Timeline 4 Back in the scene, insert a frame (not a keyframe) in Frame 5 Click Frame 5, and then select Insert, Timeline, Frame (or press F5), which extends the life of this Timeline Use Test Movie again, and you should see no change 5 Drag another instance . to bring in an uncompressed audio file and enable Flash to apply MP3 compression upon publishing the .swf. That is, you can bring in a .wav, and Flash inter- nally converts it to an MP3. Flash s. place sounds in order to hear them in the final movie? A. In the Library, in symbols, or in keyframes. B. In keyframes, no matter where they are. C. In the sound layer. 3. After importing a few. movie. In the following steps, you add some incidental sound effects. 6. Select Insert, Timeline, Layer, and name the layer Sound Effects. You’re going to inser t a sound effect when the CS4