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,
Don't see what you're looking for? Try a search.
|