Skip to content

Instantly share code, notes, and snippets.

@peterblazejewicz
Created April 22, 2011 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterblazejewicz/936484 to your computer and use it in GitHub Desktop.
Save peterblazejewicz/936484 to your computer and use it in GitHub Desktop.
locally save and load data example snippet
protected function saveToFileHandler(event:MouseEvent):void
{
var data:String = inputText.text;
debug("data to save: "+data);
var path:String = mdm.Application.path+"myFile.txt";
debug("saving data at: "+path);
mdm.FileSystem.saveFileUnicode(path, data);
// now load it back
var request:URLRequest = new URLRequest(path);
urlLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, completeHandler);
urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
urlLoader.load(request);
request = null;
}
protected function completeHandler(event:Event):void
{
urlLoader.removeEventListener(Event.COMPLETE, completeHandler);
debug("data loaded: "+urlLoader.data);
urlLoader = null;
}
protected function initApp(event:FlexEvent):void
{
mdm.Application.init(this);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment