Skip to content

Instantly share code, notes, and snippets.

@caubry
Last active December 21, 2015 20:49
Show Gist options
  • Select an option

  • Save caubry/6364388 to your computer and use it in GitHub Desktop.

Select an option

Save caubry/6364388 to your computer and use it in GitHub Desktop.
protected var fileStream:FileStream;
protected static const LOCATION_XML:String = "/d/.../myXML.xml"; // Location of your XML
public function loadXML():void
{
var fileSettings:File = File.applicationStorageDirectory.resolvePath(LOCATION_XML);
if (fileSettings.exists)
{
fileStream = new FileStream();
fileStream.addEventListener(Event.COMPLETE, onXMLContentLoaded);
fileStream.openAsync(fileSettings, FileMode.READ);
}
}
public function onXMLContentLoaded(event:Event):void
{
var myXML:XML = new XML(fileStream.readUTFBytes(fileStream.bytesAvailable));
dispatch(new GeneralInformationEvent(GeneralInformationEvent.XML_CONTENT_LOADED, myXML));
fileStream.removeEventListener(Event.COMPLETE, onXMLContentLoaded);
fileStream.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment