Requirements
- Flash MX or higher.
- A game with high score variables.
Example
1. Open up the game you wish to add this functionality to.
2. In the beginning of your ActionScript after you define your initial variables, add the following code.
|
soScores = SharedObject.getLocal("flashcookie"); //This creates a "cookie" that will save variables to the users computer.
if (soScores.data.highScore != null) //This check if the user has already played the game and has a high score saved on his/her computer. { highScore = soScores.data.highScore; //Sets the variable highScore to the stored high score on the user's computer. } |
3. You will need to change the "highScore =" to whatever your high score variable is.
4. In your ActionScript find the spot where it would make the most sense to save the user's high score, and add the following code.
| soScores.data.highScore = highScore; |
5. This line saves your highScore into the cookie on the user's computer so it can be retrieved later. You will need to change "highScore" to the name of your high score variable.
6. That's all there is to it, now when you navigate away from the page and come back your high score will still be saved in that variable. For an example on how this might work see the attached source file.












