Search tutorials
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: 8 Votes: 15 |
| » Author |
| I am young and I am a champion in flash! |
| » Download |
| Download the files used in this tutorial. |
| Download (1 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


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