Flash AS3, save and load data for iOs and android games

ε祈祈猫儿з 提交于 2019-12-24 11:36:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!