Hello guys. So i almost finished my game and i tryed to implement finaly the save/load data. I writed the codes, i used a browser to open my game and i played abit so it can save my progress. I tryed to play the game again into the same browser but it didnt saved anything. I tryed to upload it on a site to try it out if the save works but same problem if i refresh the page. I dont really know what is wrong becose the load data (i think) works well(my variables get the default value),and also i get no errors. Here are the codes:
private function saveData():void
{
Data.writeInt("TotCoins", G.Coins);
Data.writeInt("life", G.LifeLvl);
Data.writeInt("treasureBought", G.TreasureBought);
Data.writeBool("lifeShop", G.LifeDed);
Data.writeString("state", G.towerState);
for (i = 1; i <= 9; i++) {
changer = i + 0;
Data.writeBool(changer.toString(), G.Treasure[i]);
}
for (i = 1; i <= 9; i++) {
changer = i + 0;
Data.writeBool(changer.toString(), G.TreasureRelative[i]);
}
for (i = 1; i <= 99; i++) {
changer = i + 100;
Data.writeInt(changer.toString(), G.CoinsFinal[i]);
}
for (i = 1; i <= 21; i++) {
changer = i + 10;
Data.writeInt(changer.toString(), G.Levels[i]);
}
}
private function loadData():void
{
G.Coins = Data.readInt("TotCoins", 0);
G.LifeLvl = Data.readInt("life", 1);
G.TreasureBought = Data.readInt("treasureBought", 0);
G.LifeDed = Data.readBool("lifeShop", false);
G.towerState = Data.readString("state", "no");//"no"//"all towers"
G.Treasure.length = 10;
G.TreasureRelative.length = 10;
G.CoinsFinal.length = 106;
G.Levels.length = 22;
for (i = 1; i <= 9; i++) {
changer = i + 0;
G.Treasure[i] = Data.readBool(changer.toString(), false);
}
for (i = 1; i <= 9; i++) {
changer = i + 0;
G.TreasureRelative[i] = Data.readBool(changer.toString(), false);
}
for (i = 1; i <= 99; i++) {
changer = i + 100;
G.CoinsFinal[i] = Data.readInt(changer.toString(), 0);
}
for (i = 1; i <= 21; i++) {
changer = i + 10;
G.Levels[i] = Data.readInt(changer.toString(), 0);
}
}