Section 9.1. Importing Video

9.1. Importing Video

As with sound, there are two primary ways to use video in Flash. Videos can be imported into Flash and embedded in the .swf file, or they can be loaded as external assets at runtime using ActionScript. Originally, the only way to deliver video via Flash was to embed the video in a .swf file. However, technology has improved to the point that this is now recommended only for extreme circumstances. Several reasons account for this recommendation, and they are, essentially, the same reasons used to argue for the use of external sound: embedding video dramatically increases the size of your .swf, and it makes updating your project more difficult.

In most situations, your project will be better served by loading external videos during playback. However, as with sound, internal video may be preferred for a few reasons (synchronization of video with other Flash assets chief among them). The quality and performance differences between using internal and external video are great enough that embedded video is becoming increasingly rare. Still, it is good to understand both processes, so you can compare the results yourself.

9.1.1. Preparing Video for Import into Flash

Flash can import a variety of standard video formats, including MOV, AVI, MPEG, and DV. Essentially, Flash can import any standard format supported by QuickTime (Mac and Windows) or DirectShow (Windows only).

Contrary to sound, video must be compressed during the import process, so using a higher-quality source will yield better results. Remember, though, that working with large embedded videos makes your .fla file size larger and your work slower. So, some developers argue that it's easier to start with a low-quality video and then replace it with a high-quality version when nearing project completion. Ultimately, however, you are likely to only embed short videos, so the savings probably won't warrant the effort.

In the first mini-project of this chapter, you will import a small video to use as a button for viewing extreme sports content:

  1. Create a new file and save it as embedded_vid.fla in your 09 folder. Using the Modify Document menu option, change the files frame rate to 15 fps. For embedded video, the frame rate of the Flash file must match the frame rate of the video, or the playback will be affected.

  2. Select the File Import Import Video menu option.

  3. video in your 09 folder, and press the Continue button.

  4. On the Deployment screen, select "Embed video in SWF and play in timeline."

  5. The Embedding screen then displays. Configure your settings to match Figure 9-1, and then press Continue.

    Figure 9-1. The Advanced Settings screen of the Video Import Wizard

    Note: Unlike sounds, videos cannot be edited after being imported. During the import process, however, simple in-out edits can be made to identify sections of a larger video that you may want to import. This is editing at its most basic and is not a substitute for a video editor. However, it can be handy for pulling in a small segment from a pre-existing video without having to use a video editing application.

  6. The next screen is the Encoding screen. This project calls for a simple embedded file. You want to reach the widest possible user base you can, and with the smallest possible file size. For this reason, choose "Flash 7 - Low Quality (150 kbps)." (The poor source quality of this nostalgic video would render the modem quality setting unwatchable.) This option uses the Sorenson Spark codec and will actually play in Versions 6 through 8. You will use the Flash 8specific settings in an upcoming project.

    Note: Although you won't use them now, take a quick peek at the Advanced settings. Here, you can customize compression settings (rather than using a preset), crop the source video for smaller imported dimensions, and more accurately specify in and out points to import segments of a longer video. Cue points (discussed briefly in "What's Next?") are available only for external videos.

  7. Continue on to the summary screen and press Finish to start the import process.

  8. Flash will import the video and, because of the settings you chose on the Embedding screen, place the video into a movie clip on the Stage in frame 1.

    Note: Based on the "Expand timeline if needed" option on the Embedding screen, if you had chosen to place your video into a graphic symbol or embedded video object, Flash would have expanded your timeline with enough frames to accommodate the length of the video. This is a bit more cumbersome to work with, but necessary if you want to export your Flash project for broadcast video. You'll learn more about that in Chapter 15.

  9. Save your work and test your movie.

In Figure 9-2, you should see a public domain video of a film shot by none other than Thomas Alva Edison in 1899. The original film is called "Bicycle Trick Riding, no. 2" and is documentation of the slammin' extreme sports of the day. Although the 37-second film shows additional tricks, such as balancing and backwards riding, this segment has been trimmed down to a neat 4-second loop that can be used as a button.

Figure 9-2. The embedded video

To quickly demonstrate the use of imported video as a movie clip button, do the following:

  1. Give the movie clip an instance name of extremeSports_mc.

  2. Add the following script to frame 1:

     var extremeSports_mc:MovieClip; extremeSports_mc.stop(); extremeSports_mc.onRollOver = function():Void {; }; extremeSports_mc.onRollOut = function():Void {          this.stop(); }; 

  3. Save your work and test your movie.

The first line of this script tells the ActionScript compiler that extremeSports_mc is a movie clip. This static data typing will help you spot errors, as you learned in Chapter 8. The second line stops your movie clip from playing initially, and the two event handlers play and stop the clip on rollover and rollout. The effect is an interactive video that is relatively small (so it doesn't contribute mightily to file size) and tightly integrated into your .swf.

9.1.2. To Embed or Not to Embed?

Considering the technological advances that have been made in the area of Flash video, embedding clips in .swf files is largely discouraged. You've heard repeatedly in this book that file size is a major factor, but it's an even bigger issue with embedded video. For example, when a video is embedded, the entire .swf must be downloaded before the video will play. Also, the entire movie must fit into the end user's available RAM for the file to play.

There are other problems with embedded video, too. External videos look and perform better than embedded videos. Embedded videos really slow down production and have to be recompressed upon every import. Also, sync between the embedded clip's audio and video tracks can start to drift after two minutes or so.

The rule of thumb here is to use external video whenever possible. When internal video is absolutely required, add time to your production and testing schedules. Finally, if internal video is required because you ultimately want to export to video, Chapter 15 discusses possible additional options, including using linked videos that remain in QuickTime format.

Flash 8(c) Projects for Learning Animation and Interactivity
Flash 8: Projects for Learning Animation and Interactivity (OReilly Digital Studio)
ISBN: 0596102232
EAN: 2147483647
Year: 2006
Pages: 117

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: