Shared Object Not saving the level Progress
- by user3536228
I am making a flash game in which i have a variable levelState that describes the current level in which user has entered I am using SharedObject to save the progress
but it does not do so
first i declred a clas level variable
private var levelState:Number = 1;
private var mySaveData:SharedObject = SharedObject.getLocal("levelSave");
in the Main function i am checking if it is a first run of the game like below
if (mySaveData.data.levelsComplete == null)
{
mySaveData.data.levelsComplete = 1;
}
and in a function where the winning condition is checked so that levelState could be increased i am usin this sharedobject to hold the value of levelState
if (/*winniing condition*/)
levelState++;
mySaveData.data.levelsComplete = levelState;
mySaveData.flush();
setNewLevel(levelState);
}
but when i play the game clear a level and again run the game it does not start from that level it starts from beginning.