How to store Flash-based games data into server

219 views Asked by At

I have this website, I'll be happy if I could store the game progress of the user, and then retrieve it to their respective users when they login. Is there any way to do this? Maybe storing the data to a DB. I was reading on Internet and I found something about Shared Objects. I don't know if it is useful, I hope it will.. Thanks in advance and sorry for my English.

EDIT: I publish external games, I didn't develop them.

1

There are 1 answers

8
dhc On

You can use a SharedObject to store data locally, on the client side: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html

This is very easy to implement:

var user_data_so:SharedObject = SharedObject.getLocal("myUserData");
user_data_so.data.name = "User Name";
user_data_so.data.score = user_score;

SharedObjects also work with a NetConnection (see getRemote), although I haven't used this method. Other than that, a server-side script in any language you're comfortable with can accept a POST (or GET) from the client:

var req:URLRequest = new URLRequest(user_data_url);
req.data = user_data_xml;
req.contentType = "text/xml";
req.method = URLRequestMethod.POST;

// either this (will ignore server response):
sendToURL(req); 

// or (handles status, error, completion): 
var url_loader  = new URLLoader();
url_loader.addEventListener("complete",completion_handler);
url_loader.addEventListener("ioError",error_handler);
url_loader.addEventListener("securityError",error_handler);
url_loader.addEventListener("httpResponseStatus",status_handler);
url_loader.addEventListener("httpStatus",status_handler);
url_loader.load(req);