1
votes

How do I save and load using Adobe Air? This has always been something I need to know.I've asked this question before, but I've been given what to use but not how to use it.Say I save state in frame 59, I shut down and end the app.Then when I hit load, how do I get it to go back to frame 59? Please please help!

2
Also, this is for mobile. - user1666767
You can use SharedObjects to store the data (eg frame number) between sessions - see help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/… - user1901867
Did you find a solution to your question? if so, please share it, or accept an existing answer. - BadFeelingAboutThis

2 Answers

0
votes

1.Always write your current frame to a sharedObject or file

 ex. onEnterFrame(ev:Event){ //write current frame somewhere }

2.When App starte first check the file or shared object for last saved frame number. If not found by default it is the first frame, else gotoAndPlay(frame_saved);

Sorry but on this forums no one will write the app for you. you have to work yourself more to finish the solution.

0
votes

Assuming you have just the root timeline, and you don't repeat the first frame, then on the first frame of your application use this code:

//the shared object to store the state
var stateSO:SharedObject = SharedObject.getLocal("saveState");

if (stateSO.size > 0 && stateSO.data.lastFrame && stateSO.data.lastFrame != undefined) {
    //the shared object exists and has a valid value, so lets skip to that frame
    gotoAndPlay(stateSO.data.lastFrame);
}

//this function runs every frame
function saveState(e:Event = null):void {       
    stateSO.data.lastFrame = this.currentFrame; //assign the current frame number to the shared object
    stateSO.flush(); //save the cookie (shared object)
}

addEventListener(Event.ENTER_FRAME, saveState);