First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Yotam
Welcome to my tutorial! Here I will learn you how to make a system for games that loads and saves the game. First I'll learn you how to save an input text box text. Ok, here we go! First of all, make an input text box. Give it a variable name: "myText". Now make a save button and a load button. Now, to the actions of the save button!

on (release){ _root.pos = SharedObject.getLocal("game"); _root.pos.data.myText = _root.myText; }

Now, to the load button actions:

on (release){ _root.pos = SharedObject.getLocal("game"); _root,myText = _root.pos.data..myText; }

Now test your movie. Write something in the text box. Click save. Now close the movie, then open it again. Click load. It should work! The text in the text box will turn into the text you saved! Now, I'll learn you how to save a movie-clip position. Make a movie-clip. Draw in it something, and put it on the root timeline. Give it the following actions:

onClipEvent(enterFrame){ if(Key.isDown(Key.LEFT)){ this._x -= 8; } else if(Key.isDown(Key.RIGHT)){ this._x += 8; } else if(Key.isDown(Key.UP)){ this._y -= 8; } else if(Key.isDown(Key.DOWN)){ this._y += 8; } }

That was a simple actionscript that makes the movie-clip move with arrowkeys. Give the movie clip an instance name: "player". Now, to save and load! For the save button actions:

on (release){ _root.pos = SharedObject.getLocal("game"); _root.pos.data.playerx = _root.player._x; _root.pos.data.playery = _root.player._y; }

For the load button actions:

on (release){ _root.pos = SharedObject.getLocal("game"); _root.player._x = _root.pos.data.playerx; _root.player._y = _root.pos.data.playery; }

Test your movie, DONE!!!
» Level Intermediate

Added: 2007-04-10
Rating: 7.94 Votes: 16
» Author
I am young and I am a champion in flash!
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.