how to I make my flash AS3 game save progress

I have this flash game that I've been working on that works out of the browser, and I'm looking to get it to save it's progress.

I've seen multiple flash games that have accomplished this, and It appears as though they've done this client-side, and I'd like to do the same.

My game consists of 1 mxml file and a number of .as files and I compile it from the command line using flex sdk.

What do I have to do to be able to save save my game's data?

Upvotes: 0

Views: 3993

Answers (3)

Marty
Marty

Reputation: 39466

As others have mentioned, SharedObject is the tool you'll use for this.

The basics of this are to initialize a reference to a SharedObject using its static method .getLocal() first:

var mySaveData:SharedObject = SharedObject.getLocal("SomeSaveName");

The String given to this method should not contain spaces.

Once you've done this, you'll be able to use mySaveData.data, which is basically a simple object that you can attach properties to on the fly (it's dynamic):

mySaveData.data.levelsComplete = 2;

Once you've done this, you'll be able to reference that value later on using the same process:

trace( mySaveData.data.levelsComplete );

Upvotes: 2

mitim
mitim

Reputation: 3201

One way is to use flash's SharedObject to save values in to a 'flash cookie' on the client. Example can be found here: Actionscript 3 saving currentframe location to local hard drive?

Upvotes: 0

Barış Uşaklı
Barış Uşaklı

Reputation: 13532

For simple stuff you can use SharedObject

Upvotes: 1

Related Questions