如何使用 Adobe Air 保存和加载?这一直是我需要知道的。我以前问过这个问题,但我得到了使用什么,但不知道如何使用它。假设我在第 59 帧保存状态,我关闭并结束应用程序。那么当我点击加载时,我如何让它回到第 59 帧?请帮忙!
问问题
872 次
2 回答
0
1.始终将当前帧写入共享对象或文件
ex. onEnterFrame(ev:Event){ //write current frame somewhere }
2.当应用程序启动时,首先检查文件或共享对象的最后保存的帧号。如果默认没有找到它是第一帧,否则 gotoAndPlay(frame_saved);
抱歉,在这个论坛上没有人会为您编写应用程序。您必须更多地工作才能完成解决方案。
于 2013-04-13T16:03:59.813 回答
0
假设您只有根时间线,并且不重复第一帧,那么在应用程序的第一帧上使用以下代码:
//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);
于 2013-04-14T03:51:23.413 回答