Question about making stable save files in AS2

12 posts

Flag Post

I am currently using this method to generate save files in AS2, but I’ve had several beta testers complain about their save files disappearing.

var saveData:SharedObject = SharedObject.getLocal(“XXsaveFileNameXX”);

Is there another way to create a client-side save file in a way that won’t be deleted by a browser’s automatic clean-up features?

 
Flag Post

Nope you are stuck with shared objects. Are you sure the files are disappearing from the browser’s clean-up stuff or is data just being lost.

 
Flag Post

Originally posted by UnknownGuardian:

Nope you are stuck with shared objects. Are you sure the files are disappearing from the browser’s clean-up stuff or is data just being lost.

data is not just lost. it is intentionally removed.

since Adobe integrated flash with the browsers enough to clear SOLs like standard cookies, i’ve found it impossible to maintain saves for games because all browsers (with their, of course, different settings) use the same storage and delete stuff. it would be nice if either the user or the developer could flag something to be less volatile, but no one gets an option in this behaviour.

 
Flag Post

Data lost as in they are playing the game and dev forgets to call flush(). So they had data, but it never went out to the .sol.

 
Flag Post

The data is flushed when the SWF closes.

 
Flag Post

Amazing. I was unaware of such a feature. Good job Adobe.

 
Flag Post

Except that may not be enough. When the application closes, what gets flushed is whatever happens to be in mysharedobject.data. If the program did not update the contents of mysharedobject recently, then anything that changed since the last manual save will be lost.

For instance, let’s say you keep a high score variable in your shared object. Whenever the game ends, you need to manually check if the score reached was better than the high score and if so do something like

mysharedobject.data.highscore = currentscore;

If the player happens to close the game after they beat their previous high score but before this check occured, closing the application will simply cause the old high score to be flushed and the new one to be lost.

And if you don’t save raw data but serialize it before saving it should be obvious that simply closing the application will do nothing to save the most current information.

 
Flag Post

Well obviously…

 
Flag Post
Originally posted by UnknownGuardian:

Amazing. I was unaware of such a feature. Good job Adobe.

Only if the page is navigated away or the browser is closed cleanly. A crash will not call flush();

 
Flag Post

Obviously this won’t help you much if you are making a portable .swf file, but the HTML5/JavaScript localStorage is much more stable than cookies/Flash storage, it’s typically not cleared out randomly here and there.

 
Flag Post

Is there a way to use a .js to convert a flash storage file to a more stable state, or does that only apply to Java based games.?

 
Flag Post
Originally posted by nosajimiki:

Is there a way to use a .js to convert a flash storage file to a more stable state, or does that only apply to Java based games.?

You can do save games letting the user save an encrypted file to a location of his choosing, but you need as3.