ADOBE FLEX 3
Developer Guide
418
Microsoft changed the way streaming media is handled in Microsoft Internet Information Services (IIS) 6.0 web
server from earlier versions. Earlier versions of IIS do not require any modification to stream Flash Video. In IIS 6.0,
the default web server that comes with Windows 2003, the server requires a MIME type to recognize that FLV files
are streaming media.
When SWF files that stream external FLV files are placed on Microsoft Windows Server® 2003 and are viewed in a
browser, the SWF file plays correctly, but the FLV video does not stream. This issue affects all FLV files placed on
Windows Server 2003, including files you make with earlier versions of the Flash authoring tool, the Macromedia
Flash Video Kit for Dreamweaver MX 2004 from Adobe. These files work correctly if you test them on other
operating systems.
For information about configuring Microsoft Windows 2003 and Microsoft IIS Server 6.0 to stream FLV video, see
www.adobe.com/go/tn_19439.
About targeting local FLV files on the Macintosh
If you attempt to play a local FLV from a non-system drive on an Apple® Macintosh® computer by using a path that
uses a relative slash (/), the video will not play. Non-system drives include, but are not limited to, CD-ROMs, parti-
tioned hard disks, removable storage media, and connected storage devices.
Note: The reason for this failure is a limitation of the operating system, not a limitation in Flash Player.
For an FLV file to play from a non-system drive on a Macintosh, refer to it with an absolute path using a colon-based
notation (:) rather than slash-based notation (/). The following list shows the difference in the two kinds of notation:
Slash-based notation: myDrive/myFolder/myFLV.flv
Colon-based notation: (Mac OS®) myDrive:myFolder:myFLV.flv
You can also create a projector file for a CD-ROM you intend to use for Macintosh playback. For the latest infor-
mation on Mac OS CD-ROMs and FLV files, see www.adobe.com/go/3121b301.
Example: Video Jukebox
The following example builds a simple video jukebox which dynamically loads a list of videos to play back in a
sequential order. This allows you to build an application that lets a user browse through a series of video tutorials, or
perhaps specifies which advertisements should be played back before delivering the user’s requested video. This
example demonstrates the following features of ActionScript 3.0:
Updating a playhead based on a video files playback progress
Listening for and parsing a video files metadata
Handling specific codes in a net stream
Loading, playing, pausing, and stopping a dynamically loaded FLV
Resizing a video object on the display list based on the net streams metadata
To get the application files for this sample, see www.adobe.com/go/learn_programmingAS3samples_flash. The
Video Jukebox application files can be found in the folder Samples/VideoJukebox. The application consists of the
following files:
ADOBE FLEX 3
Developer Guide
419
Loading an external video playlist file
The external playlist.xml file specifies which videos to load, and the order to play them back in. In order to load the
XML file, you need to use a URLLoader object and a URLRequest object, as seen in the following code:
uldr = new URLLoader();
uldr.addEventListener(Event.COMPLETE, xmlCompleteHandler);
uldr.load(new URLRequest(PLAYLIST_XML_URL));
This code is placed in the VideoJukebox class’s constructor so the file is loaded before any other code is run. As soon
as the XML file has finished loading, the
xmlCompleteHandler() method is called which parses the external file
into an XML object, as seen in the following code:
private function xmlCompleteHandler(event:Event):void
{
playlist = XML(event.target.data);
videosXML = playlist.video;
main();
}
The playlist XML object contains the raw XML from the external file, whereas the videosXML is an XMLList object
which contains just the video nodes. A sample playlist.xml file can be seen in the following snippet:
<videos>
<video url="video/caption_video.flv" />
<video url="video/cuepoints.flv" />
<video url="video/water.flv" />
</videos>
Finally, the xmlCompleteHandler() method calls the main() method which sets up the various component
instances on the display list, as well as the NetConnection and NetStream objects which are used to load the external
FLV files.
Creating the user interface
To build the user interface you need to drag five Button instances onto the display list and give them the following
instance names:
playButton, pauseButton, stopButton, backButton, and forwardButton.
For each of these Button instances, you’ll need to assign a handler for the
click event, as seen in the following
snippet:
playButton.addEventListener(MouseEvent.CLICK, buttonClickHandler);
pauseButton.addEventListener(MouseEvent.CLICK, buttonClickHandler);
stopButton.addEventListener(MouseEvent.CLICK, buttonClickHandler);
backButton.addEventListener(MouseEvent.CLICK, buttonClickHandler);
forwardButton.addEventListener(MouseEvent.CLICK, buttonClickHandler);
The buttonClickHandler() method uses a switch statement to determine which button instance was clicked, as
seen in the following code:
File Description
VideoJukebox.as The class that provides the main functionality of the application.
VideoJukebox.fla The main application file for Flash.
playlist.xml A file that lists which video files will be loaded into the video jukebox.

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.