Created
April 22, 2011 11:36
-
-
Save peterblazejewicz/936484 to your computer and use it in GitHub Desktop.
locally save and load data example snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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