//Set up the list box, call function VideoThumb to create the actual thumbnails list.rowHeight = 70; list.cellRenderer = "VideoThumb"; list.selectable = true; //create new empty listener object listListener = {}; //Function to handle what happens when an item in the list is selected listListener.change = function( evtobj ) { var nav = list.dataProvider[list.selectedIndex]; nc = new NetConnection(); //create a connection nc.connect( null ); //null connection for progressive download ns = new NetStream(nc); //create a stream video.attachVideo(ns); //pipe stream to this video object // walk through the chosen item, build and play it var reset = true; for ( var i = 0; i < nav.childNodes.length; i++ ) { var stream = nav.childNodes[i]; if ( stream.nodeName == "stream" ) { // build path to flv, and play it myStreamPath = nav.attributes.url + "/" + stream.attributes.name; ns.setBufferTime(10); ns.play( myStreamPath); reset = false; } } } //Add an event listener on the list, when it triggers, run the listListener function to repopulate the list list.addEventListener("change", listListener); //Function that loads the XML file, parses it, and builds the list of available video clips var xmllist = new XML(); //setup a variable to hold the XML xmllist.ignoreWhite = true; xmllist.load( "playlist-demo-1.xml" ); //load the XML file //The following gets called when the XML has been loaded xmllist.onLoad = function( status ) { if ( !status ) trace( status ); var entries = this.childNodes[0]; var playlists = {}; var nav = []; for ( var i = 0; i < entries.childNodes.length; i++ ) { var entry = entries.childNodes[i]; if ( entry.nodeName == "listitem" ) //builds array of video clip names playlists[entry.attributes.name] = entry; else if ( entry.nodeName == "menu" ) { //builds array of available videos for ( var j = 0; j < entry.childNodes.length; j++ ) nav[j] = playlists[entry.childNodes[j].attributes.name]; } //end else if } //end if //sends the array of videos to the listbox UI list.dataProvider = nav; } //end xmllist.onload //resizes the video object to the width and height of the clip function onVideoResize() { if ( video.width != video._width || video.height != video._height ) { video._width = video.width; video._height = video.height; //center video in playback area newx = (360 - video._width)/2; newy = (440 - video._height)/2; video._x = newx; video._y = newy; } } setInterval( onVideoResize, 200 ); //keeps checking video size