AS3 browse and load video

Hey all,

I’m currently working on a AS3 AIR project which involves allowing the user to browse a video file and load that same video onto the stage. I’ve managed to allow the user to browse for a video file type and according to my traces it completes loading the video but this is as far as I’ve got. There is plenty of tutorials which involve how to load video files from local sources or external links but nothing to show me what to do with a browsed file to display it on the stage. Here is the code so far for browsing to the video file:

private function browseVideo():void {
	fileReference = new FileReference();
	fileReference.addEventListener(Event.SELECT, videoFileSelected);
	
	var videoTypeFilter:FileFilter = new FileFilter("Video files", "*.3g2; *.3gp; *.asf; *.asx; *.avi; *.flv; *.m4v; *.mov; *.mp4; *.mpg; *.rm; *.swf; *.vob; *.wmv;");
	
	fileReference.browse([videoTypeFilter]);
}

private function videoFileSelected(e:Event):void {
	fileReference.addEventListener(Event.COMPLETE, onVideoFileLoaded);
	fileReference.addEventListener(IOErrorEvent.IO_ERROR, onVideoFileLoadError);
	fileReference.load();
}

function onVideoFileLoaded(e:Event):void {
	var fileReferenceTarget:FileReference = e.target as FileReference;

	var data:ByteArray = fileReferenceTarget["data"];
	
	fileReference.removeEventListener(Event.COMPLETE, onVideoFileLoaded);
	fileReference.removeEventListener(IOErrorEvent.IO_ERROR, onVideoFileLoadError);
	
	var videoLoader:Loader = new Loader();
	videoLoader.loadBytes(data);
	videoLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onVideoLoaderComplete);
	
	trace("video file loaded");
}

function onVideoFileLoadError(e:Event):void {
	fileReference.removeEventListener(Event.COMPLETE, onVideoFileLoaded);
	fileReference.removeEventListener(IOErrorEvent.IO_ERROR, onVideoFileLoadError);
	
	trace("video file load failed");
}

function onVideoLoaderComplete(e:Event):void {
	var loadedContent:DisplayObject = e.target.content;
	var loader:Loader = e.target.loader as Loader;
	
	scope.addChild(loader);
}