Hey everyone so what I've been trying ti accomplish with no success is how to display my Movie Clip object named achiev_10
when the nScore
which is a number equal to 10.
Here is what I have so far in my Shared Object Data.
In my Constructor I have this:
//Initialize our shared object give it a path to save local data
sharedObject = SharedObject.getLocal("GeometryBlast");
if (sharedObject.data.highScore == null)
{
// checks if there is save data
trace("No saved data yet."); // if there isn't any data on the computer...
sharedObject.data.highScore = nScore; // ...set the savedScore to 0
} else
{
trace("Save data found."); // if we did find data...
loadData(); // ...load the data
}
Then in the saveData();
function I have this:
public function saveData():void
{
if (nScore > sharedObject.data.highScore )
{
sharedObject.data.highScore = nScore;
}
menuEnd.bestScore.text = " " + sharedObject.data.highScore;
sharedObject.flush();
//trace("Data Saved!");
//sharedObject.clear();
if (nScore == 10)
{
achiev_10 = new Achievment_10();
menuEnd.addChild(achiev_10);
achiev_10.x = stage.stageWidth / 2;
achiev_10.y = stage.stageHeight / 2;
sharedObject.flush();
}
}
Now currently in the if (nScore == 10)
where I add the Move Clip, it does work and it does display. But when i go back to check my Move Clip achievement it dissapears. I don't really know what i need to do to save the data if the save data.highscore is equal to 10 then always display that achievement.
I also tried this but nothing:
if (sharedObject.data.highScore == 10)
{
achiev_10 = new Achievment_10();
menuEnd.addChild(achiev_10);
achiev_10.x = stage.stageWidth / 2;
achiev_10.y = stage.stageHeight / 2;
sharedObject.flush();
}
please help thank you!
You will need several functions to work with SharedObject. But you should know, user can clear values from the SharedObject, and achievements will be lost.
Now you can work with scores: