[b]private function browseForFile():void
[/b]{
var xmlTypes:FileFilter = new FileFilter("XML (*.xml)", "*.xml");
var xmlFile:Array = new Array(xmlTypes);
refUploadFile = new FileReference();
refUploadFile.browse(xmlFile);
refUploadFile.addEventListener(Event.SELECT,onFileSelect);
refUploadFile.addEventListener(Event.COMPLETE,onFileComplete);
}
private function onFileSelect(event:Event):void
{
trace("Selected");
refUploadFile.removeEventListener(Event.SELECT,onFileSelect);
refUploadFile.addEventListener(Event.COMPLETE,onFileComplete);
refUploadFile.load();
}
[b]private function onFileComplete(event:Event):void[/b]
{
var newXML:XML = refUploadFile.data as XML; // [u]Here is the problem, how to convert the data I get to an XML file, using this way makes the newXML=NULL[/u][i][/i]
refUploadFile.removeEventListener(Event.COMPLETE,onFileComplete);
refUploadFile = event.currentTarget as FileReference;
}
|