Adobe AIR的共享对象 - 安卓/ iOS的 - 在更新未找到 [英] Adobe AIR SharedObject - Android/iOS - On update not found

查看:211
本文介绍了Adobe AIR的共享对象 - 安卓/ iOS的 - 在更新未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题状态,我的用户对iOS和Android都报告它们保存数据时,我推的更新推崇店面被删除。游戏保存和恢复正常的应用程序加载和出口数据。我并没有改变任何信息保存位置或包名...只是单纯的bug修复,建设,推动。

任何澄清将是有益的,还是建议冗余数据备份方案的我应该追求,以确保最终用户的体验是从今以后,没有受到不利影响。我也想更好地了解如何测试这是一个发布包不允许更新市场安装的应用程序。

  VAR因此:共享对象= SharedObject.getLocal的(存储);
变种U:用户;
如果(so.data!= NULL){
    U = so.data.user;
}

跟踪(加载应用程序......);

如果(U!= NULL){
    跟踪(LOADING保存数据);
    用户= U;
}其他{
    跟踪(NO SAVE数据存在);
    用户=新用户();
}
 

解决方案

我已经发现了这个问题的原因,似乎Adobe已经确认并修复问题,以及(如AIR 3.5)。 https://bugbase.adobe.com/index.cfm?event=bug& ; ID = 3347676

共享对象存储在用户根据所使用的应用程序的SWF命名的目录中,因此,如果您的应用程序正在运行关myApp.swf的共享对象将被存储在目录对myApp。如果更改此SWF的名称(即您的AIR项目相应的XML构建表的配置文件)的任何后续版本将存储的共享对象在新的位置。

在此错误所描述的问题是专门记为iOS,其中,应用以上,但在一个单独的位置记在你的项目的XML构建手册中的文件名属性的描述是不存储在共享对象在相应的SWF的位置。

我也发现了Adobe的确宽恕使用一个共享对象永久存储的移动平台。

我已经制定了未来的版本中一个简单的备份保存冗余,以防将来的更新无法坚持的共享对象。

  / **最后时间戳深深的保存完成* /
私人VAR mLastSave:数= -1;


/ **
 *保存全局对象的状态及其所有
 *子对象。
 * @警告
 *所有对象必须实现一个公开状态变量。
 *私有变量不会被保存的持久性管理器中
 * /
公共职能保存():无效{
    VAR因此:共享对象= SharedObject.getLocal的(存储);
    so.data.user =用户;
    so.flush();
    saveDeep();
}


/ **
 *保存共享对象,以表示移动applicationStorageDirectory。
 * /
公共职能saveDeep():无效{
    //保存在第一个应用程序保存或之后
    //每5分钟
    如果(mLastSave == -1 || mLastSave<的getTime()+ 300000){
        mLastSave =的getTime();

        var文件:文件= File.applicationStorageDirectory.resolvePath(userSave);
        VAR FILESTREAM:的FileStream =新的FileStream();
        fileStream.open(文件,FileMode.WRITE);
        变种BA:的ByteArray =新的ByteArray();
        ba.writeObject(用户);
        fileStream.writeBytes(BA);
        fileStream.close();
    }
}


/ **
 *加载从共享对象的应用程序会默认
 *如果共享对象DNE试图从加载
 * applicationStorageDirectory,如果既不存在
 *创建新的用户对象
 * /
公共职能的load():无效{

    registerClassAlias​​(用户,用户);

    //创建/读取一个名为用户数据共享对象
    VAR因此:共享对象= SharedObject.getLocal的(存储);
    变种U:用户;
    如果(so.data!= NULL){
        U = so.data.user;
    }

    跟踪(加载应用程序......);

    如果(U!= NULL){
        跟踪(LOADING保存数据);
        用户= U;
    }其他{
        跟踪(NO SAVE数据存在);
        var文件:文件= File.applicationStorageDirectory.resolvePath(userSave);
        如果(file.exists){
            跟踪(发现userSave备份-attempting加载);
            VAR FILESTREAM:的FileStream =新的FileStream();
            fileStream.open(文件,FileMode.READ);
            变种BA:的ByteArray =新的ByteArray();
            fileStream.readBytes(BA);
            fileStream.close();
            尝试{
                用户=(ba.readObject()为用户);
            }赶上(五:引发EOFError){
                跟踪(共享对象不存在,试图userSave负载失败);
            }
        }其他{
            用户=新用户();
            跟踪(创建新用户...);
        }
    }
}
 

As the title states, my user's on iOS and Android are reporting their save data has been deleted when I push an update to the respected storefronts. The game saves and restores data properly on application load and exit. I have not changed any save information locations or package names... Just mere bug fixes, build, push.

Any clarification would be helpful, or proposed redundant data backup scheme's I should pursue to ensure the end-user experience is from henceforth not affected negatively. I would also like to understand better how I can test this as a release package is not allowed to update a market installed application.

var so:SharedObject = SharedObject.getLocal("storage"); 
var u:User;
if(so.data != null){
    u = so.data.user;
}

trace("Loading application...");

if(u != null){
    trace("LOADING SAVE DATA");
    user = u;
}else{
    trace("NO SAVE DATA EXISTS");
    user = new User();
}

解决方案

I have discovered the cause of this issue and it seems that Adobe has identified and fixed the issue as well (as of AIR 3.5). https://bugbase.adobe.com/index.cfm?event=bug&id=3347676

SharedObjects are stored within a directory named according to the SWF used by your application, so if your application is running off "myApp.swf" the SharedObject will be stored in a directory "myApp". If you change the name of this SWF (i.e. the corresponding XML build sheet configuration file for your AIR project) any subsequent builds will store their SharedObjects in a new location.

The issue described in this bug was specifically denoted for iOS, wherein the application was not storing the SharedObject in the corresponding SWF location as described above but in a separate location denoted by the "filename" attribute in your project's XML build sheet.

I have also discovered that Adobe does indeed condone the use of a SharedObject for persistent storage on a mobile platform.

I have developed a simple backup for future version save redundancy in case future updates fail to persist the SharedObject.

/** the last timestamp a deep save was completed */
private var mLastSave:Number = -1;


/**
 * save the state of the globals object and all of its
 * sub objects.
 * @warning
 * all objects must implement variables in a "public" state.
 * Private variables are not saved within the persistance manager
 */
public function save():void{
    var so:SharedObject = SharedObject.getLocal("storage");
    so.data.user = user;
    so.flush();
    saveDeep();
}


/**
 * Save the SharedObject to denoted mobile applicationStorageDirectory.
 */ 
public function saveDeep():void{
    // save on first application save or after
    // every 5 minutes
    if(mLastSave == -1 || mLastSave < getTime() + 300000){
        mLastSave = getTime();

        var file:File = File.applicationStorageDirectory.resolvePath("userSave");
        var fileStream:FileStream = new FileStream(); 
        fileStream.open(file, FileMode.WRITE);
        var ba:ByteArray = new ByteArray();
        ba.writeObject(user);
        fileStream.writeBytes(ba);
        fileStream.close();
    }   
}


/**
 * Load the application from the SharedObject be default
 * if the SharedObject DNE attempt to load from the 
 * applicationStorageDirectory, if neither exist
 * create new User object
 */ 
public function load():void{

    registerClassAlias("user", User);

    // Create/read a shared-object named "userData"
    var so:SharedObject = SharedObject.getLocal("storage"); 
    var u:User;
    if(so.data != null){
        u = so.data.user;
    }

    trace("Loading application...");

    if(u != null){
        trace("LOADING SAVE DATA");
        user = u;
    }else{
        trace("NO SAVE DATA EXISTS");
        var file:File = File.applicationStorageDirectory.resolvePath("userSave");
        if(file.exists){
            trace("Found userSave backup -attempting to load");
            var fileStream:FileStream = new FileStream(); 
            fileStream.open(file, FileMode.READ);
            var ba:ByteArray = new ByteArray();
            fileStream.readBytes(ba);
            fileStream.close();
            try{
                user = (ba.readObject() as User);
            }catch( e : EOFError ){
                trace("SharedObject did not exist, attempted userSave load, failed");
            }
        }else{          
            user = new User();
            trace("created New user...");
        }
    }
}

这篇关于Adobe AIR的共享对象 - 安卓/ iOS的 - 在更新未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆