问题
I'm trying to make games for iOS and Android. How do I save data to the gadget, and also how do I load it? The data that I want to save to the user device is basically just a bunch of strings. Kindly help please.
And by the way, I'm using Flash CS6 for the game.
回答1:
The SharedObject class should do fine for you. The attributes you write/read can be of any type (String, Array, Number, Boolean, XML, ...).
Basic example:
var scores : Array = new Array(10, 20, 30);
var my_so : SharedObject = SharedObject.getLocal("myGameHighscore");
my_so.data.scores = scores; // set scores var to data object of SharedObject
my_so.flush(); // writes the data instantly
// To retreive your scores simply use getLocal again and then do something like:
trace(my_so.data.scores[0]); // will trace first element of scores array "10"
Please refer to this URL: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html
来源:https://stackoverflow.com/questions/24074092/flash-as3-save-and-load-data-for-ios-and-android-games