如何使我的闪存AS3游戏保存进度使我、闪存、进度、游戏

2023-09-09 21:54:07 作者:醉绾青丝蛊

我有这个Flash游戏,我一直在努力的工作出了浏览器,而我​​希望得到它来保存它的进步。

I have this flash game that I've been working on that works out of the browser, and I'm looking to get it to save it's progress.

我已经看到了,已经完成了这个多重闪光游戏,它看起来好像他们已经做到了这一点客户端,我想这样做。

I've seen multiple flash games that have accomplished this, and It appears as though they've done this client-side, and I'd like to do the same.

我的游戏包括1 MXML 文件和若干。如文件和我的命令编译使用Flex SDK行。

My game consists of 1 mxml file and a number of .as files and I compile it from the command line using flex sdk.

我有什么做的,能够保存保存我的游戏数据?

What do I have to do to be able to save save my game's data?

推荐答案

正如其他人所说, 共享对象 是你会使用这个工具。

As others have mentioned, SharedObject is the tool you'll use for this.

这样做的基本是初始化一个引用共享对象使用它的静态方法 .getLocal()第一

The basics of this are to initialize a reference to a SharedObject using its static method .getLocal() first:

var mySaveData:SharedObject = SharedObject.getLocal("SomeSaveName");

给该方法的字符串不应该包含空格。

The String given to this method should not contain spaces.

一旦你做到了这一点,你就可以使用 mySaveData.data ,这基本上是,你可以在飞行中附加属性(它是动态的)一个简单的对象:

Once you've done this, you'll be able to use mySaveData.data, which is basically a simple object that you can attach properties to on the fly (it's dynamic):

mySaveData.data.levelsComplete = 2;

一旦你做到了这一点,你就可以在以后参考使用相同的过程,值:

Once you've done this, you'll be able to reference that value later on using the same process:

trace( mySaveData.data.levelsComplete );