PDA

View Full Version : [AS2] Save Game?


Mayhew
12-04-2008, 06:24 PM
Alright, so I'm down to this. My game needs to be able to save data.
Say for example: I have Dynamic Text as a movie clip. The MC instance name is score, and the dynamic text instance is score. SO! This MC has this tini-weenee code:
onClipEvent(load){
this.score.text = 0;
}Now, say, if my player wishes to save and close the game, how would the player be able to save the score that is inside this MC? D:

fnx
12-04-2008, 09:28 PM
Using shared objects? :)

Mayhew
12-04-2008, 10:38 PM
I could use an example, if you please. I've never used localInfo = SharedObject.getLocal(); if that's what you mean.

(?): How can the score.text that's inside the score mc be saved into the player's hard drive, THEN be called back when the player runs the game again? :o

dialectric
12-04-2008, 11:17 PM
Hi,

This question is asked often. Flash cannot save files. Most people use php to save files, usually .txt or .xml, to the server where the swf is. In short, you need to use a php script on the same server as your flash swf, since flash can't write to files, but php can, and flash can communicate with php. You could alternatively use Adobe Air, or some 3rd party projector software.

this thread has a fairly thorough discussion, including example php files:
http://www.actionscript.org/forums/s....php3?t=168250

- dialectric

fnx
12-05-2008, 10:13 AM
The request, if I understood it correctly, was to save and resume score.
To do that with php, you have to manage the user identity too, which I think wouldn't
be too easy and "distract" from the real task.

To me the easiest way is to use shared object, you play the game, decide to exit so
save the score and close. Once you reload the flash, it resumes the score from the
shared object (much like login forms "remember me").
Of course this solution would manage only one user per machine.

As a reference you can see this:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html

Komal Sharma
12-08-2008, 06:45 AM
Hi
Thanks it works ....

raikado
09-06-2009, 12:32 AM
I know this topic is old, but can someone give me an example of how to use
sharedOject()?