At 7/1/14 01:08 PM, Joyhype wrote:
I'm trying to make it so it's like "Jetpack joyride" you collect coins from killing bad guys and it gets saved into a "bank" in the game that you can use it to spend money on, but if you quit the game I don't want it so that you start back at 0 coins but rather x amount of coins you collected last time.
To store data after they close the game you would use a SharedObject. A SharedObject is a piece of data that persists after close. you simply say:
var saveFile:SharedObject = SharedObject.getLocal("game name");
To retrieve previous data, and then to save data it's just:
saveFile.data.coins = 10;
saveFile.flush();
just know that some people have their flash player set up so that it can't store data, if you call flush it will crash on them, you'll have to use a try...catch
try {
saveFile.flush
} catch (e:Error) {
trace("Player cannot save data");
}