Hi, I’ve never used shared objects before and I’m running into some trouble which I hope somebody can help me with. The code below is on a movie clip and when the player wins the game if the score they achieved is their highest I want the game to save it and hold that value as the “bestscore”. All that I can get from in when I try to display the best score in a dynamic text box is “undefined”.Can anybody advise or do I need to go into more detail?
onClipEvent (load) {
saveData = SharedObject.getLocal("SaveFileName");
if (saveData.data.exists == 1)
{
bestscore = saveData.data.bestscore;
}
else
{
bestscore = 0;
saveData.data.bestscore = bestscore;
saveData.data.exists = 1;
saveData.flush();
}
}
onClipEvent (enterFrame) {
bestscore = saveData.data.bestscore;
if (_root.player.win)
{
if (_root.player.score >= bestscore)
{
saveData.data.bestscore = _root.player.scorescore;
saveData.flush();
}
}
}