397
Chapter 20: Working with video
Flash® video is one of the standout technologies on the Internet. However, the traditional presentation of video—in
a rectangular screen with a progress bar and some control buttons underneath—is only one possible use of video in
a Flash application. Through ActionScript™, you have fine-tuned access to and control over video loading, presen-
tation, and playback.
Contents
Basics of video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
Understanding the Flash Video (FLV) format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
Understanding the Video class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
Loading video files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Controlling video playback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Streaming video files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
Understanding cue points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
Writing callback methods for onCuePoint and onMetaData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Using cue points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
Using video metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
Capturing camera input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
Advanced topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Example: Video Jukebox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
Basics of video
Introduction to working with video
One important capability of Adobe® Flash® Player is the ability to display and manipulate video information with
ActionScript in the same way that you can manipulate other visual content such as images, animation, text, and so
on.
When you create a Flash Video (FLV) file in Adobe Flash CS3 Professional, you have the option to select a skin for
your video including common playback controls. However, there is no reason you need to limit yourself to the
options available. Using ActionScript, you have fine-tuned control over loading, displaying, and controlling playback
of video—meaning you could create your own video player skin, or use your video in any less traditional way that
you want.
Working with video in ActionScript involves working with a combination of several classes:
Video class: The actual video content box on the Stage is an instance of the Video class. The Video class is a
display object, so it can be manipulated using the same techniques that can be applied to other display objects, such
as positioning, applying transformations, applying filters and blending modes, and so forth.
NetStream class: When youre loading a video file to be controlled by ActionScript, a NetStream instance is used
to represent the source of the video content—in this case, a stream of video data. Using a NetStream instance also
involves using a NetConnection object, which is the connection to the video file—like the tunnel that the video data
is fed through.

Get ADOBE® FLEX® 3: PROGRAMMING ACTIONSCRIPT™ 3.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.