储存并负荷状态AS3 + Adob​​e AIR的 [英] Save & load State AS3 + Adobe Air

查看:167
本文介绍了储存并负荷状态AS3 + Adob​​e AIR的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何保存和加载使用Adobe空气?这一直是我的东西需要之前know.I've问过这个问题,但我一直在考虑用什么,但没怎么用it.Say我保存状态帧59,我关闭,并结束该应用程序。然后,当我打的负载,我怎么得到它回到59帧?请请帮助!

How do I save and load using Adobe Air? This has always been something I need to know.I've asked this question before, but I've been given what to use but not how to use it.Say I save state in frame 59, I shut down and end the app.Then when I hit load, how do I get it to go back to frame 59? Please please help!

推荐答案

假设你刚才的根时间轴,并且不重复的第一帧,那么你的应用程序的第一帧上使用code:

Assuming you have just the root timeline, and you don't repeat the first frame, then on the first frame of your application use this code:

//the shared object to store the state
var stateSO:SharedObject = SharedObject.getLocal("saveState");

if (stateSO.size > 0 && stateSO.data.lastFrame && stateSO.data.lastFrame != undefined) {
    //the shared object exists and has a valid value, so lets skip to that frame
    gotoAndPlay(stateSO.data.lastFrame);
}

//this function runs every frame
function saveState(e:Event = null):void {       
    stateSO.data.lastFrame = this.currentFrame; //assign the current frame number to the shared object
    stateSO.flush(); //save the cookie (shared object)
}

addEventListener(Event.ENTER_FRAME, saveState);

这篇关于储存并负荷状态AS3 + Adob​​e AIR的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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