all groups > flash actionscript > may 2004 >
You're in the

flash actionscript

group:

Making highscores screen


Making highscores screen Gimpy987
5/2/2004 7:23:37 PM
flash actionscript:
Re: Making highscores screen kglad
5/2/2004 9:24:31 PM
Re: Making highscores screen Gimpy987
5/2/2004 10:24:19 PM
Re: Making highscores screen Gimpy987
5/2/2004 10:24:25 PM
Re: Making highscores screen mandingo
5/3/2004 7:10:17 AM
The first question is where do you want to store the results? On a server
somewhere online or locally?

If locally, it can all be done with a localSharedObject

highScores = SharedObject.getLocal("hiScores","/");
if(highScores.data.gameScores == undefined){
highScores.data.gameScores = new Array();
}

At the conclusion of the game, create an object for your data...

for(var k = 0; k<highScores.data.gameScores.length; k++){
if(score > highScores.data.gameScores[k].newScore){
highScores.data.gameScores.pop();

highScore= new Object();
highScore.newScore = score; // the gameScore
highScore.playerName = playerName; // can get this from an input textField
that they complete
highScore.gameDate = currentDate; // use the Date Object to create the date in
the format you want to appear.

highScores.data.gameScores.push(highScore);
highScores.data.gameScores.sortOn(newScore);
return;
}
}

Not tested as I don't have Flash on this PC but basically, test that the new
score is greater than at least on score in the array... if it is, pop off the
last score (because the array should be sorted so the lowest score is in the
end position), then create the new information in an object and push it to the
Array, then re-sort the array...
the return will break out of the statement if it satisfies the criteria.

Hopefully that will give you a start point to a local save solution...

cheers,
AddThis Social Bookmark Button