Importing Video Files

Once you have access to a video in the Flash video format (.flv or .f4v), you're ready to begin importing the video file into Flash. When you begin this process, your video can be on your computer or it can be on the web, where it's served up by a Flash Media Server. In this section, you see step-by-step examples for both scenarios.

When you have a video on your computer in one of Flash's two video formats (.flv or .f4v), it's easy to import it into your Flash project. By making a couple of choices along the way, you can give your Flash audience standard controls to play and pause your video and adjust its sound. To work on the following exercise, you can download the video 11-4_Building_Implode.flv from the Missing CD page at www.missingmanuals.com/cds.

When you add video to your Flash project using this method, Flash creates a link between the Flash file and your project. Even after you publish a Flash .swf file for final distribution, the Flash file and your video file remain separate. If the project is for a website, you need to place both the Flash .swf file and the video file (.flv or .f4v) on the website, ideally in the same folder. To make things easy for yourself, it's best to put your Flash video in same folder where you save your Flash work file (.fla) and publish your Flash animation (.swf).

  1. Create a new Flash document, and then save it.

    It's always good to name and save your Flash projects at the beginning. It's even more helpful when you work with external video files, as you do in this project. A name like building_bye_bye.fla might be appropriate for this one.

  2. Place the Flash video 11-4_Building_Implode.flv in the same folder where you save your Flash file (.fla) and your published Flash file (.swf).

    This step makes it easier for Flash to create a link to the video file. After publishing the .swf, as long as both files are located in the same folder, the link between the two will continue to work.

  3. In Flash, select File→Import→Import Video.

    The Import Video dialog box appears, as shown in Figure 11-15, with several options you can choose using radio buttons. The question is: Where is your video file? Either it's on your computer, or it's stored on a web server with Flash Media Server software.

  4. Click the radio button for "On your computer".

    Flash wants to know where the file is right now, so it can load it into your project. At this step, don't jump ahead and start thinking about where the final project is going to be published.

  5. Click the Browse button, and then locate and select your video file.

    Flash displays a standard Open window similar to the one you use to open a Flash document. It should be easy to locate 11-4_Building_Implode.flv, because it's in the same folder as your Flash file. After you select the file, its name and path show up under the Browse button. Now that Flash knows where the file is located, it can work with the video.

  6. Tell Flash how you want to work with the video by clicking the radio button labeled: "Load external video with playback component".

  7. Click Continue to move to the next Import Video step.

    The Import Video box changes to show skinning options for your video. A skin is a sort of container that adds Play/Pause/Stop type controls to your video, as shown in Figure 11-16.

  8. From the Skin drop-down box, choose SkinOverAll.swf.

    Use the drop-down menu to choose an Adobe predesigned skin, as shown in Figure 11-17. Adobe supplies a whole slew of skins with different combinations of controls. SkinOverAll includes all the controls, so this exercise shows you what's available. When you tackle a real-world project, you may find you don't need quite so many gadgets on your videos.

    There are also options to provide no controls at all (usually not the best option) or to use a custom-designed skin. For example, you might want to put your client's logo on the video skin as another way to establish his brand.

  9. Click Continue.

    Flash displays the Import Video: Finish Video Import dialog box you see in Figure 11-18. The details shown may not seem that important until it's time to publish your Flash project on a web page. Here's a translation for each of the lines:

  10. Click Finish.

    The Import Video: Finish Video Import dialog box disappears. As promised, you see the video player on your stage along with the skin (video controls). There's also copy of the video in the Library, as shown in Figure 11-19.

  11. Press Ctrl+Enter (⌘-Return on a Mac) to test your Flash project and view the video.

    In the Flash animation, you see your video running. Using the skin controls, you can start and stop the playback.

Surprisingly, importing a video file that's stored on the Web isn't much different from importing one that's on your computer, as described on Importing Video Files. The Flash video file may be in a standard web server or one that has Flash Media Server software. (Don't worry if you don't have a video file stored on a web server; there's an example file you can practice with, as you'll see in the following steps.)

The only differences in the importing process happen at the very beginning.

  1. Select File→Import→Import Video.

    The Import Video: Select window appears.

  2. Turn on the radio button next to "Already deployed to a web server, Flash Video Streaming Service, or Flash Media Server" (Figure 11-15). In the URL box, type the web address where the file lives, and then click Continue.

    The URL for the practice file is http://examples.oreilly.com/flashcs4mm/11-4_Building_Implode.flv. When you click Continue, the Import Video: Skinning window you see in Figure 11-17 appears.

The rest of the steps are identical to those for importing a Flash video file on your own computer. You can pick up the process at step 8 on Importing a Flash Video File Stored on Your Computer.

In Flash-speak, once your video is added to your Flash file, it's called the FLVPlayback component. Components are prebuilt widgets that you drop into your animations. Someone else went to all the trouble of building (and hopefully testing) the component. All you have to do is drop a component into your Flash project and let it do its stuff. Components save you design and programming time, so it's worthwhile to learn about them. There's a whole chapter on components (Chapter 16), but since you're already using one in this example, it's worth covering some of the specific ways you can customize the FLVPlayback component.

Most components provide a few options that let you customize them for your nefarious purposes. For example, in the case of the FLVPlayback component, you can change the playback behavior of the video and the appearance of the video controls. You can even change the video source file if you have a newly edited and improved video. You change the settings for a component by changing its parameters. Here's how to view and edit the FLVPlayback parameters:

  1. In Flash, click the FLVPlayback component on the stage.

    As with other objects, you select the video playback component and then modify it using the settings in the Properties panel.

  2. In the Properties Panel, open the Component Parameters subpanel.

    The Component Inspector panel opens in Flash. The name of each parameter (setting) is listed on the left, and its value is shown on the right.

  3. Make changes to the FLVPlayback parameters.

    You can change multiple parameters. For example, to change the appearance of the skin (video playback controls), click skinAutoHide, and then set the value to "true". To change the color of the skin, click the skinBackgroundColor swatch, and then choose a new color from the color picker.

Here's a complete description of the parameters for the FLVPlayback component:

  • align. Determines the alignment of the video image when the video scaleMode (below) isn't set to exactFit.

  • autoPlay. If set to "true", the video automatically plays when the Flash animation frame that holds it is loaded.

  • cuePoints. You can add cue points to your video when it's encoded, as explained on Adding Cue Points to Your Video. Or you can add them using the FLVPlayback component. Click the magnifying glass to open a window where you can add manual cue points by typing in a name and a time.

  • islive. Used with a Flash Media Server, this value is set to "true" when streaming a live performance.

  • preview. Used for the live preview feature that helps you test the parameter settings. Click the magnifying glass to see your video with the current settings.

  • scaleMode. This setting determines how the video image sizes itself after it's loaded. There are three options: noScale, where the video uses the size of the Flash video source file; maintainAspectRatio, where the video retains its proportions when enlarged or shrunk; and exactFit, which forces the video to fit the dimension of the component as shown in the Properties panel.

  • skin. The name and path for the .swf file that adds playback controls to the video.

  • skinAutoHide. If set to "true", the playback controls disappear unless the mouse is hovering over the video image.

  • skinBackgroundAlpha. Playback controls can be transparent. A value of 1.0 = opaque and 0 = invisible. So, a value of .8 provides an 80 percent opacity effect.

  • skinBackgroundColor. Click the color swatch, and then choose a new color from the color picker.

  • source. The name and path for the Flash video file.

  • volume. Sets the audio volume for video playback. A value of 1.0 = full volume and 0 = no volume. So a value of .5 provides half the available volume for audio playback.