【问题标题】:Flash AS3, save and load data for iOs and android gamesFlash AS3,为 iOs 和 android 游戏保存和加载数据
【发布时间】:2014-06-06 04:19:50
【问题描述】:

我正在尝试为 iOS 和 Android 制作游戏。如何将数据保存到小工具,以及如何加载它?我想保存到用户设备的数据基本上只是一堆字符串。请帮忙。

顺便说一句,我正在使用 Flash CS6 进行游戏。

【问题讨论】:

标签: actionscript-3 flash


【解决方案1】:

SharedObject 类应该适合您。您写入/读取的属性可以是任何类型(字符串、数组、数字、布尔值、XML 等)。

基本示例:

        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"

请参考这个网址:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html

【讨论】:

    猜你喜欢
    • 2011-12-02
    • 2017-12-22
    • 2011-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-26
    • 1970-01-01
    相关资源
    最近更新 更多