package { import flash.display.MovieClip; import flash.net.URLLoader; import flash.net.URLRequest; import flash.events.Event; import fl.controls.listClasses.CellRenderer; import fl.controls.ScrollBarDirection; import flash.text.TextFormat; public class VideoPlaylist extends MovieClip { private var xmlLoader:URLLoader; private var textStyle:TextFormat; public function VideoPlaylist():void { // Load the playlist file, then initialize the media player. xmlLoader = new URLLoader(); xmlLoader.addEventListener(Event.COMPLETE, initMediaPlayer); xmlLoader.load(new URLRequest("http://econwebdesign.com/templates/terry_bryan/flash/playlist.xml")); // Format the tileList, specify its cellRenderer class. tileList.setSize(200, 240); tileList.columnWidth = 180; tileList.rowHeight = 60; tileList.direction = ScrollBarDirection.VERTICAL; tileList.setStyle("cellRenderer", Thumb); textStyle = new TextFormat(); textStyle.font = "Tahoma"; textStyle.color = 0xFF0000; textStyle.size = 11; tileList.setRendererStyle("textFormat", textStyle); } public function initMediaPlayer(event:Event):void { var myXML:XML = new XML(xmlLoader.data); var item:XML; for each(item in myXML.vid) { // populate playlist. // Get thumbnail value and assign to cellrenderer. var thumb:String; if(item.hasOwnProperty("@thumb")>0) thumb = item.@thumb; // Send data to tileList. tileList.addItem({label:item.attribute("desc").toXMLString(), data:item.attribute("src").toXMLString(), source:thumb});; } // Select the first video. tileList.selectedIndex = 0; // Listen for item selection. tileList.addEventListener(Event.CHANGE, listListener); // And automatically load it into myVid. myVid.source = tileList.selectedItem.data; // Pause video until selected or played. myVid.pause(); } // Detect when new video is selected, and play it function listListener(event:Event):void { myVid.play(event.target.selectedItem.data); } } }