Our Flash tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website.  Home Flash & Swish Flash Tutorials Save A High Score Locally
Your Ad Here

Save A High Score Locally


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.




Author's URL: Tutorial Scene
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

Internet & computing Flash is a vector-based moving graphics format created by Macromedia for the publication of animations on the World Wide Web. More Flash & Swish: Most Popular Materials | Fresh Materials | More Flash Tutorials at FlashPerfection.com

Add comments to "Save A High Score Locally"

Only registered users can write comment

No comments yet...