ADOBE FLEX 3
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();
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;
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:
<video url="video/caption_video.flv" />
<video url="video/cuepoints.flv" />
<video url="video/water.flv" />
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
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
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
The buttonClickHandler() method uses a switch statement to determine which button instance was clicked, as
seen in the following code:
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.