Trouble adding video controls to video selected by XML comboBox

Posted by user560128 on Stack Overflow See other posts from Stack Overflow or by user560128
Published on 2011-01-02T03:49:26Z Indexed on 2011/01/02 3:53 UTC
Read the original article Hit count: 330

Filed under:
|
|
|

Hello, it's been a few years since I've touched flash, so perhaps I'm just overlooking something. If anyone could look at the code and offer any suggestions that would be awesome.

What's working, I select a video from a combobox that is populated from an XML file, pick the video and it plays.

I've been trying to add pause/play, stop, forward and reverse functionality, once I get that to work I also want to add a video scrubber(slider), and previous/next buttons to go to the previous/next video as listed in the xml file.

At the moment I have a component button on the stage called playButton, which I'm trying to use for pause/play functionality. Below is my code, the player control is at the very bottom. Thanks.

import fl.data.DataProvider;

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
var videosXML:XML = new XML();
var loader:URLLoader = new URLLoader();
var request:URLRequest= new URLRequest("xml/videos.xml");
var videos:Array = new Array({label:"Select a Video",data:""});
var client:Object = new Object();  

theVideo.attachNetStream(ns);
ns.client = client;
 loader.addEventListener(Event.COMPLETE,loaderOnComplete);
 loader.load (request);

function loaderOnComplete(event:Event):void{
    videosXML = new XML(event.target.data); 
    for each (var video:XML in videosXML.video){
        videos.push({label:video.name.toString(),data:video.url.toString()});
    }
    moviesCB.dataProvider = new DataProvider(videos);
}

moviesCB.addEventListener(Event.CHANGE, changeHandler);

function changeHandler(event:Event):void {
    if(ComboBox(event.target).selectedItem.data != ""){
        ns.play(ComboBox(event.target).selectedItem.data);
    }
};

client.onMetaData = metadataHandler;
function metadataHandler(md:Object):void{
}

//player controls
playButton.onRelease = function() {
    ns.pause();
}

© Stack Overflow or respective owner

Related posts about flash

Related posts about actionscript-3