如何使我的闪存AS3游戏保存进度 [英] how to I make my flash AS3 game save progress

查看:121
本文介绍了如何使我的闪存AS3游戏保存进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个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?

推荐答案

正如其他人所说,<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html"相对=nofollow> 共享对象 是你会使用这个工具。

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.

一旦你做到了这一点,你就可以使用<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html#data"相对=nofollow> 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 );

这篇关于如何使我的闪存AS3游戏保存进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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