XML File Read
Process 1 to read File :
var m_FileRef:FileReference;
public function btnLoadClickHandler(event:Event):void {
m_FileRef = new FileReference();
m_FileRef.addEventListener(Event.SELECT, onBrowse);
var imagesFilter:FileFilter = new FileFilter("*.skd", "*.skd;");
m_FileRef.browse([imagesFilter]);
}
public function onBrowse(e:Event):void {
m_FileRef.addEventListener(Event.COMPLETE, onComplete);
m_FileRef.load();
}
public function onComplete(e:Event):void {
lblMsg.text = m_FileRef.name;
Process 2 for Browse File:
var XMLFile:File;
public function btnLoadClickHandler(event:Event):void
{
var imagesFilter:FileFilter = new FileFilter("SarakuDesign[*.skd;]", "*.skd;");
XMLFile = new File();
XMLFile.browseForOpen("Select design File", [ imagesFilter ]);
XMLFile.addEventListener(Event.SELECT, XMLSelected, false, 0, true);
}
XML LOAD CODE
public function XMLSelected(event:Event):void
{
XMLFile = File(event.target);
var request:URLRequest = new URLRequest(XMLFile.nativePath);
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, showXML);
xmlLoader.load(request);
OR
var request:URLRequest = new URLRequest(event.target.nativePath);
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, loadXML);
xmlLoader.load(request);
}
function showXML(e:Event):void {
XML.ignoreWhitespace = true;
var design:XML = new XML(e.target.data);
var i:Number;
for (i=0; i < design.DesignType.length(); i++) {
lblMsg.text = design.DesignType[0].text();
}
}