People are losting gave save

4 posts

Flag Post

Hey,
I decided to write here because I totally don’t know why people losts save in my games.

This bug was in my first game, i created second, used almost similar save system and bug was still. I’m newbie developer, i really don’t know why it don’t work.
Maybe anyone can help me? I really please.
Important information – Not everyone lost saves, but a lot of people(maybe half of them), I don’t lost saves for example.

I’m using this save system:
http://www.newgrounds.com/bbs/topic/838366

 
Flag Post

I’m not quite sure but I’m pretty sure ISO.getLocal() should only be called in the variable definition.
That could be totally wrong what I just said there, so please someone correct me if I’m wrong.

But here’s the way I save stuff in my games, the save system you’re using seems to be filled with a lot of useless stuff:

var SO:SharedObject = SharedObject.getLocal(“game_name”);

function saveGame() {
SO.data.playerX = player.x;
SO.data.playerY = player.y;
SO.flush();
}

function loadGame() {
player.x = SO.data.playerX;
player.y = SO.data.playerY;
}

You could change out the number values with whatever you wanted (booleans, strings, etc).
Hope this helped!

EDIT: Added in .data’s, sorry, typo. (tested and it works now)

 
Flag Post

The code posted in that thread is correct, but lacks the variable definition of myLSO (something that is allowed in AS2 but not in AS3), and is overly complicated. You should try to reproduce the problem.

@Glutenfree4u: You must save the variables in the data property of the sharedobject, not as properties of the sharedobject itself. Your code won’t work.

 
Flag Post

Just trying to cover all bases, but do they have their flash storage set to unlimited? If not, newer saves from other games on that site will overwrite older ones. Also, right after the last line in the saveGame function: myLSO.data.myObj = myObj;, you’ll want to add myLSO.flush(); to force everything to be written. If you don’t, you’re at the mercy of flash to flush() at its discretion, which may not happen under various circumstances. (such as if flash crashes)