Ex09 (Flash) - Working With Sound and Video
Ex09 (Flash) - Working With Sound and Video
Sound and video files add new dimensions to your projects. Import files polished in other
applications, such as Adobe After Effects, or perform simple edits on sound files directly in Flash
CS3.
Lesson Overview
This lesson will take approximately 90 minutes to complete. If needed, remove the previous lesson folder from
your hard drive, and copy the Lesson09 folder onto it.
Start the lesson by viewing the finished animated zoo kiosk. You'll create the kiosk by adding sound and video
files to a project in Flash.
1. Double-click the 09End.swf file in the Lesson09/09End folder to play the animation.
View the movie of the zoo director, who appears on the screen, speaks, and then disappears. Click a
sound button to hear an animal sound. Click a thumbnail button to view a short movie about the animal.
In this lesson, you'll create the sound buttons and import audio files for them. You'll create movie
thumbnail buttons, import movies, and use ActionScript to attach the buttons to the movies. You'll also
animate the zoo director video so that it moves onto the screen appropriately.
2. Double-click the 09Start.fla file in the Lesson09/09Start folder to open the initial project file in Flash.
3. Choose File > Save As. Name the file 09_workingcopy.fla, and save it in the 09Start folder. Saving a
working copy ensures that the original start file will be available if you wish to start over.
To set up the file, import the assets from an Illustrator file and add an Actions layer.
2. In the Import dialog box, select the Lesson09_assets.ai file in the Lesson09/09Start folder, and click
Open or Import.
3. In the Import To Stage dialog box, select all the layers. Select Flash Layers from the Convert Layers To
menu. Select Place Objects At Original Position; no other options should be selected.
4. Still in the Import To Stage dialog box, select the Video Button 1 layer, and select Create Movie Clip.
Name the instance video_button1.
5. Repeat step 4 to create movie clips for the Video Button 2, Video Button 3, and Video Button 4 layers.
Name the instances video_button2, video_button3, and video_button4, respectively. Click OK to import
the file.
To lock all the layers at once, click the lock icon above the layer names. Then, you
can quickly unlock a single layer.
7. Select Show All from the View menu in the Edit bar to see all the elements on the Stage.
There are three sound buttons in the final kiosk, each playing a different animal sound. You'll create a button
symbol, configure its rollover states, and import a sound for the button. Then, you'll duplicate that button and
adapt it to create buttons for two additional sounds.
Button symbols include four rollover states in the Timeline: Up, Down, Over, and Hit. You'll convert the speaker
icon and text to a button, configure the rollover states for the button, and draw a rectangle background for the
button's hit area.
1. Select the Sound Buttons layer. The group in the lower-right corner (Sound 1 and a speaker symbol) is
selected.
2. Choose Modify > Convert To Symbol. In the Convert To Symbol dialog box, select Button, and name the
button sound_button1. Click OK.
3. Double-click the instance of sound_button1 on the Stage to edit it. You may need to zoom in a little to
see the button more clearly.
4. Select Layer 1, and then select the group on the Stage. Choose Modify > Break Apart to break the group
into pieces. Click elsewhere on the Stage to deselect the objects.
6. Click the Insert Layer icon, and with the new layer selected, choose Edit > Paste In Place. The speaker
symbol appears on the new layer.
8. Click the Insert Layer icon two times to create two more layers. Name the new layers Sound and
Highlight.
9. Rearrange the layers to appear in the following order, from top to bottom: Sound, Icon, Text, Highlight.
10. Select the Down frame on the Text layer, and press F5 to insert frames across all the button states.
11. Select the Down frame on the Icon and Sound layers, and press F6 to create a keyframe for each layer.
12. Select the Down frame on the Icon layer, and then select the speaker symbol on the Stage. In the
Transform panel, scale the symbol to 150%.
Note
14. Select the Rectangle tool. Specify no stroke. Select a black fill with an Alpha value of 50%. Draw a
rectangle approximately the same size as the red rectangle above the button (behind Guess this animal
sound).
16. Select the Down frame on the Highlight layer, and press F6 to insert a keyframe. Select the black
rectangle on the Stage, and change its fill color to #B52823, with an Alpha value of 100%.
17. Select the Hit frame on the Highlight layer, and press F5.
Note
The Hit frame determines the active area of the button. Because the hit area is the same as the rectangle
shape, the button will be active whenever the mouse hovers over or clicks the rectangle.
Most sound files, especially short WAV files, are small enough that you can import the full file into a Flash
document. Two sound files are already included in the library, but you'll import the Monkey.wav file and assign
it to the button symbol you created.
2. Select the Monkey.wav file in the Lesson09/09Start/Sounds folder, and click Open (Windows) or Import
To Library (Mac OS).
4. In the Property inspector, select Monkey.wav from the Sound menu, and select Start from the Sync menu.
The sound clip you imported is a bit longer than you need. You'll shorten the sound file using the Edit Envelope
dialog box, so that only the first two sections of the waveform remain. Then, you'll apply a fade so that the
sound gradually decreases as it ends.
1. Select the Down frame on the Sound layer. In the Property inspector, click Edit.
2. In the Edit Envelope dialog box, click the Zoom Out icon until you can see the entire waveform, which
includes four distinct sections.
4. Select Fade Out from the Effect menu so that the volume diminishes gradually at the end of the sample.
Click OK to accept the changes you've made.
5. Choose Control > Test Movie, and click the button again. The sound should be about half as long as it
was the first time.
Duplicating Buttons
You need three buttons for animal sounds, and they're all similar. You'll duplicate the first button, and then
make a few adjustments to it to reuse it for the second and third buttons.
Note
3. Duplicate the button one more time, naming the third button sound_button3.
5. Select the Sound Buttons layer. Drag an instance of the sound_button2 symbol onto the Stage, placing it
beneath the first button. Double-click the second button to edit it.
6. Select the text with the Text tool, and change the number to 2.
7. Select the Down frame on the Sound layer. In the Property inspector, select Lion.wav from the Sound
menu, and select Start from the Sync menu.
9. Select the Sound Buttons layer, drag an instance of the sound_button3 symbol beneath the other
buttons on the Stage, and double-click it to edit it.
Aligning Buttons
In the kiosk, the buttons appear in a column. The easiest way to arrange them is to use the Align panel, which
you've used in other lessons.
2. Select all three buttons on the Stage. Make sure Align To Stage is deselected in the Align panel, and then
click the Align Horizontal Center icon.
3. With all three buttons still selected, use the arrow keys on your keyboard to nudge the buttons so that
they are centered beneath the text that reads Guess this animal sound.
4. Click elsewhere on the Stage to deselect the buttons. Then, select the instance of the sound_button3
symbol.
5. Using the arrow keys, nudge the button so that it's aligned with the bottom of the semi-transparent
thumbnail bar.
8. Choose Control > Test Movie. Test each button, and then close the preview window.
There are four movie thumbnail buttons on the kiosk, and each plays a short movie of an animal at the zoo.
You'll apply the drop shadow filter to the thumbnail movie clip symbols you imported earlier, and then you'll
create a button symbol with distinct rollover states. As you did with the sound buttons, you'll duplicate the
initial button and make changes to it for the other movie thumbnail buttons.
Note
You can apply the drop shadow filter to the thumbnails because they are movie clip symbols. If you had
imported them as graphic symbols, you wouldn't be able to apply filters.
You imported thumbnails in the Illustrator file, converting them to movie clip symbols as you did so. Now, you'll
add drop shadows to each, and then convert them to button symbols. As you did with the sound buttons,
you'll configure rollover states.
1. Unlock the Video Button layers, and select the four movie clip thumbnails on the Stage. (Zoom out to see
them, if necessary.)
2. In the Filters panel, click the Add Filter icon ( ) and select Drop Shadow from the menu. Set the Blur X
and Blur Y values to 10, the Distance to 10, and the Strength to 80%.
Note
The Filters panel is typically docked with the Property inspector. Click the Filters tab to display the Filters
panel.
3. Click elsewhere on the Stage to deselect the thumbnails. Then, select the first thumbnail (the image of
penguins), and press F8 to convert it to a symbol. Select Button, set the registration point to the center,
name the symbol video_button1, and click OK.
5. Press Shift and select all four frames in Layer 1, and then press F6 to insert a keyframe in each one.
6. Select the Over frame, and select the button on the Stage. In the Property inspector, select Brightness
from the Color menu, and select -35 for the percentage.
7. Select the Down frame, and select the symbol on the Stage. In the Property inspector, select Brightness
from the Color menu and select -35% for the percentage.
9. Select the symbol on the Stage and press the Down Arrow key three times and the Right Arrow key three
times to nudge the thumbnail so that the center point is slightly off-center from the button.
11. Choose Control > Test Movie. Roll the mouse over the first button; the image should darken. Click the
first button; the button should appear as if it is pressed toward the Stage. Close the preview window.
You've created one thumbnail button, and you'll duplicate it to create the remaining three buttons. You'll swap
the movie clip in each button, and then replace the video button movie clips on the Stage with the
video_button buttons.
1. Right-click (Windows) or Control-click (Mac OS) the video_button1 symbol in the Library panel, and select
Duplicate. In the Duplicate Symbol dialog box, select Button, and name the symbol video_button2. Click
OK.
3. Select the Up frame in Layer 1, and then select the symbol on the Stage. In the Property inspector, click
Swap.
5. Repeat steps 3 and 4 to swap the video file for the Over and Down frames.
Note
You do not need to swap video files for the Hit frame, because the Hit state is not displayed; it just
determines the active area of the button.
6. Scrub the Timeline. The thumbnail is different from that in the first button, but the filter and property
adjustments remain the same.
7. Repeat steps 1-5 to create buttons named video_button3 and video_button4, applying images from the
Video Button 3 and Video Button 4 folders, respectively.
9. Select the Video Button 1 layer, and then select the first video button on the Stage.
11. Select the Video Button 2 layer, and then select the second video button on the Stage.
12. In the Property inspector, click Swap. Select the video_button2 symbol, and click OK.
Note
Be sure to select video_button2 in the Swap Symbol dialog box, and not Video Button 2.
13. Select Button from the Instance Behavior pop-up menu (Movie Clip is currently displayed). Type
video_button2 for the instance name, if it isn't already there.
14. Repeat steps 11-13 for the third and fourth buttons.
16. Choose Control > Test Movie. As you move the mouse over the thumbnails, they should display the
appropriate Up, Down, and Over states. Close the preview window.
Currently, many layers contain just a single frame. You need to create new layers for frame labels, the pop-up
video of the zookeeper, and the video player. Then, add frames to all the layers so that they each have at
least 50 frames. Next, you'll label frames and add stop actions so that the script will stop while the movie
plays.
1. Select the Sound Buttons layer, and click the Insert Layer icon three times. Name the new layers Labels,
Pop Up Video, and Video Player.
2. Select frame 50 on the Actions layer, and then press Shift and select frame 50 on the Background Photo
layer, so that frame 50 is selected on all the layers. Press F5 to insert frames for all layers.
3. Select frame 10 in the Actions and Labels layers, and press F6 to insert a keyframe on each layer. Add
keyframes to frames 20, 30, and 40 in the Actions and Labels layers.
4. Select frame 10 in the Labels layer. In the Property inspector, type penguins in the Frame Label box.
5. Repeat step 4 to label frame 20 mandrill, frame 30 tiger, and frame 40 lion.
6. Choose Window > Actions to open the Actions panel, and then select frame 1 in the Actions layer.
stop();
8. Add stop actions to frames 10, 20, 30, and 40 in the Actions layer. Close the Actions panel.
You've created the thumbnail movie buttons. Now you need to prepare the movies to play when the buttons
are depressed. You'll import one video file and encode it in FLV format; the other movies are already in FLV
format for you. Then, use the FLV playback component controls to link the appropriate movie file with the frame
for each button, and to turn autoplay on or off. Finally, you'll use ActionScript to move the Timeline to the
appropriate frame when each button is clicked.
When you import video, you can choose to embed it, which places the video in the Timeline so that it becomes
part of the Flash document, or load it externally, so that it remains a separate file. Embedded video works best
for smaller video clips without audio tracks; if you're using video clips longer than 10 seconds, load external
video files and download the video progressively (so the viewer can watch it as it is downloading) or stream
video using Flash Video Server.
You can import video files into Flash and convert them into FLV files at the same time. The Import Video wizard
creates an FLV playback component, which contains the video file and the skin, or controls, that you've
selected.
3. In the Import Video wizard, select On Your Computer, and click Browse (Windows) or Choose (Mac OS).
4. In the dialog box, select Penguins.mov from the Lesson09/09Start folder, and click Open. Click Next or
Continue in the wizard.
5. From the deployment options, select Progressive Download From A Web Server. Click Next or Continue.
Note
Progressive download lets the video file play as it downloads to the viewer's computer.
6. Select the Encoding Profiles tab, and then select Flash 8 High Quality (700 kbps) from the profile menu.
7. Select the Crop And Resize tab. Select Resize Video, and type 480 in the Width field and 320 in the
Height field. Click Next or Continue.
Note
The skin determines the look and feel of the video's controls. You can use one of the skins provided with
Flash, or you can customize your own. To preview a skin, select it from the Skin menu.
9. Review the settings for the imported video file, and then click Finish to encode the file. By default, your
video file will be named penguins.flv and saved in the same folder as the Flash document you're working
on, which is also where your final swf file will be saved.
Note
The encoding process can be complex. How long it takes depends on your computer's processor speed
and memory, the complexity and length of the video, and the encoding options you choose.
11. Choose Control > Test Movie. The video begins streaming. Use the controls to play, stop, and change the
volume for the movie. Close the preview window.
The Flash Import Video wizard includes many options. Which options you choose depends on your
target audience, the size of the video you're importing, and the initial format of the movie file.
Deployment Options
This option lets you stream the video using HTTP streaming. If you use this option, you
need to upload the FLV file to the server along with the SWF file.
This option lets you upload your video to a Flash Media Server, if your service provider
hosts one.
This option lets you upload your video to a Flash Media Server that you host, rather than
one your service provider hosts.
This option is only available if you are creating a Flash document for Flash Lite 2.0 or later.
It bundles a device video file within the SWF file for use with Flash Lite 2.0 enabled devices
(such as mobile phones and handheld computers).
This option embeds the video in the Flash document and includes its frames in the Timeline.
However, embedding is only recommended for short video clips with no audio track.
Additionally, embedding a video file substantially increases the SWF file size.
This option lets you publish your Flash content as a QuickTime 4 movie and creates a
pointer to a QuickTime video file. You must publish the SWF file as a QuickTime video. You
cannot display a linked QuickTime clip in SWF format.
Encoding Options
If you're converting a video file to FLV format, you'll have several encoding options.
Encoding profiles contain settings optimized for specific versions of Flash Player and for different
download speeds. When you select a profile, a summary of its settings appears. You can
customize those settings by clicking the Video or Audio tab and selecting a different option.
Skinning Options
The video's skin determines the look and feel of the controls, and their position on the Stage.
Select a skin to see a preview of its appearance. You can design a custom skin in Flash, save it as
an SWF file, and link to it from the Skinning window of the Import Video wizard.
The FLV playback component lets you control which video plays, whether the video plays automatically, and
other aspects of playback. You'll turn autoplay off for the initial penguin movie, so that it doesn't begin playing
until the viewer presses the Play button. Then you'll change the FLV playback component options at different
frames to play the appropriate movies for each button, and to turn autoplay on, so that the movies start
playing immediately when the button is pressed.
3. Test the movie again. The penguin video doesn't begin playing until you press the Play button.
4. Select frame 10 of the Video Player layer, and press F6 to insert a keyframe.
5. Select the FLV playback component on the Stage. In the Parameters panel, change the autoPlay
parameter to true.
Note
In the final movie, when you click the penguin button, the script will move to frame 10 in the Timeline, and
the movie will play immediately.
6. Select frame 20 of the Video Player layer, beneath the mandrill frame label. Press F6 to insert a keyframe.
7. Select the FLV playback component on the Stage. In the Parameters panel, click the source parameter. In
the box next to it, click the magnifying glass icon.
8. In the Content Path dialog box, click the folder icon, select the Mandrill.flv file in the Lesson09/09Start
folder, and click Open. Then click OK to close the Content Path dialog box.
Note
The autoPlay parameter should already be set to true because the keyframe has the properties of the
previous keyframe.
9. Select frame 30 of the Video Player layer, press F6 to insert a keyframe, and change the source
parameter to the Tiger.flv file.
10. Select frame 40 of the Video Player layer, press F6 to insert a keyframe, and change the source
parameter to the Lion.flv file.
A different video file is associated with each section of the Timeline (Penguins.flv with frame 10, Mandrill.flv with
frame 20, and so on). Now you need to write the ActionScript that moves the playhead to the appropriate
frame in the Timeline when the button is clicked.
You can use the same set of code for each button, with minor changes. The first line of code adds an event
listener, similar to the one you used in Lesson 7. The event listener listens for the button click, and then runs
the function (clickListener1, clickListener2, and so on),
UMinho :: Ciências da Comunicação
which you define in the following lines.
Page 22 of 31
The function
Design e Multimédia
moves the playhead to the appropriate frame in the Timeline. When the playhead moves, the appropriate
video file plays, according to the controls in the FLV playback component.
1. Select frame 1 in the Actions layer, and open the Actions panel.
Note
this.video_button1.addEventListener(MouseEvent.CLICK,clickListener1);
3. Define the clickListener1 function by typing the following lines in the Actions panel:
function clickListener1(event:MouseEvent):void {
gotoAndPlay("penguins");
}
Note
You can also copy the lines of the script from the Actions panel in the 09End.fla file.
this.video_button2.addEventListener(MouseEvent.CLICK,clickListener2);
function clickListener2(event:MouseEvent):void {
gotoAndPlay("mandrill");
}
this.video_button3.addEventListener(MouseEvent.CLICK,clickListener3);
function clickListener3(event:MouseEvent) {
gotoAndPlay("tiger");
}
this.video_button4.addEventListener(MouseEvent.CLICK,clickListener4);
function clickListener4(event:MouseEvent) {
gotoAndPlay("lion");
}
For the thumbnail buttons, you used video files that fill the FLV playback component. Sometimes, though, you
want to use a video file that doesn't include a background. For this project, the zoo director was filmed in front
of a green screen, which was removed using Adobe After Effects. When you use the video in Flash, the zoo
director appears to be in front of the Flash background.
You'll import the video file, which is already in FLV format, into an FLV video component. However, you won't
include a skin. The zoo director will appear directly on the Stage.
You'll convert the FLV file to a movie clip symbol, so that you can apply the drop shadow filter to set it off from
the background. Then, you'll animate and mask the clip, so that the zoo director appears just before he begins
speaking and disappears when he has finished.
1. Select the first frame in the Pop Up Video layer, and choose File > Import > Import Video.
2. In the Import Video wizard, select On Your Computer, and click Browse or Choose. Select the Popup.flv
file in the Lesson09/09Start folder, and click Open. Click Next or Continue to proceed to the next window
in the wizard.
3. From the deployment options, select Progressive Download From A Web Server. Click Next or Continue.
4. Select None from the Skin menu, and click Next or Continue.
To see the entire Stage, choose Show All from the pop-up menu just above the
Stage
7. Choose Control > Test Movie to see the video file that uses alpha channels. Close the preview window.
l Use a green background that is flat, smooth, and free of shadows, so that the
color is as pure as possible.
l Minimize the light that reflects off the green screen onto the subject.
Import the file as footage into After Effects, create a new composition, and drag it
onto the Composition Timeline.
Create a garbage mask to roughly outline the shape and remove most of the
background. But be sure the subject never moves outside the mask!
Use the Color Range keying effect to delete the rest of the background. You may
need to do some fine-tuning with the Matte Choker and Spill Suppressor effects. A
spill suppressor removes the light that splashes onto the edges of the subject.
Export the video file to Flash Video (FLV) format directly from After Effects. Be sure to
select Encode Alpha Channel. The alpha channel is the selection around the subject.
Encoding the alpha channel ensures that the video exports without a background.
To distinguish the video from the background, apply a drop shadow filter. First, convert the video to a movie
clip symbol so that you can animate the clip. Then, within that movie clip symbol, convert the video to a movie
clip symbol so that you can apply a drop shadow to it.
2. Double-click the movie symbol on the Stage to edit it. Rename Layer 1 Video in the symbol Timeline.
3. Select the video file on the Stage, and press F8 to convert it into a symbol again. Select Movie Clip, set a
center registration point, and name the symbol popUp_video. Then click OK.
4. Select the movie clip symbol on the Stage. In the Filters panel, click the Add Filter icon, and select Drop
Shadow.
5. Set the Blur X and Blur Y options to 10, set the Distance to 10, and set the Strength to 50%.
Use motion tweens to animate the clip so that it slides in before it plays and slides out when it has finished.
1. Select the Video layer, and then click the Insert Layer icon. Name the new layer Actions.
3. Select any frame between the keyframes on frames 1 and 15. In the Property inspector, select Motion
from the Tween menu.
4. Select frame 1 on the Video layer, and then select the instance of the movie clip on the Stage.
6. Select frame 175 on the Video layer, and press F6 to add a keyframe. Add another keyframe at frame
190.
7. Select any frame between 175 and 190. In the Property inspector, select Motion from the Tween menu.
8. Select frame 190 in the Video layer, select the video on the Stage, and drag the video straight down
below the Stage.
Note
You've animated the video clip to move off the screen as the zoo director finishes speaking. However, the
exact timing of the end of the speech depends on the computer playing the video. You may need to move
the motion tween earlier or later in the Timeline.
stop();
The stop action keeps the script from repeating the motion tween.
A mask will show the movie clip only within a specific area of the Stage. You'll create a simple mask using the
Rectangle tool.
1. Select the Video layer, and click the Insert Layer icon. Name the new layer Mask.
2. Select the Rectangle tool, with no stroke and a solid fill in any color.
3. Draw a rectangle on the Stage, and select it with the Selection tool.
4. In the Property inspector, set the width and height of the rectangle to 300. Set the X and Y values to 0.
5. Right-click (Windows) or Control-click (Mac OS) the Mask layer, and select Mask.
6. Choose Control > Test Movie to see the effect. The video should disappear when it slides off the Stage.
You've made an ordinary project much more engaging with sound and video files imported from other sources.
Review Answers
1 To edit the length of a sound clip, select the frame that contains it, and click Edit in the Property
inspector. Then, move the time slider in the Edit Envelope dialog box.
2 The skin is the combination and appearance of video controls, such as Play, Fast Forward, and
Pause buttons. You can choose from a wide array of combinations, with the buttons in different
positions, and you can customize the skin. If you don't want viewers to have control over the
video, apply no skin.
3 When you embed a video clip, it becomes part of the Flash document and is included in the
Timeline. Because embedded video clips significantly increase the size of the document and
produce audio synchronization issues, it's best to embed video only if it is less than 10 seconds
in length and contains no audio track.
4 A green screen is a solid color background shot behind a video subject. The solid background is
then removed from the footage in an application such as After Effects, so that the subject can
be placed in front of a different background.