First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
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
(10 being the highest)
» 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!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
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: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.