Flash 8: Projects for Learning Animation and Interactivity (OReilly Digital Studio)
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:
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:
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. |