如何在Flash中创建保存按钮?
我有一个游戏,我使用Flash cs5 ActionScript3。我想为游戏创建一个保存按钮。当玩家加载游戏时,保存的游戏将打开。谢谢。
I have a game and I used Flash cs5 ActionScript3. I want to create a save button for the game. When the player loads the game, the saved game will open. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看
SharedObject
班级;特别是其数据
属性。本质上:
像这样定义一个
SharedObject
:var saveData:SharedObject = SharedObject.getLocal("MyGame");
使用
data
属性存储信息,下次打开应用程序时可以访问这些信息。请务必注意,只有当.swf
保留在同一位置(网络上或本地)时,数据才会被保留。if(!saveData.data.test)
saveData.data.test = "Test string";
您将能够访问存储在
数据中的信息 预期对象:
trace(saveData.data.test); // 测试字符串
这个想法是,最初您将创建游戏首次启动时可能想要保存的所有属性:
当您点击“保存”时,覆盖这些属性:
Look at the
SharedObject
class; particularly itsdata
property.Essentially:
Define a
SharedObject
like so:var saveData:SharedObject = SharedObject.getLocal("MyGame");
Use the
data
property to store information which will be accessible the next time you open the application. It's important to note that the data will only be retained if the.swf
remains in the same location, either on the web or locally.if(!saveData.data.test)
saveData.data.test = "Test string";
You'll be able to access the information you've stored in the
data
object as expected:trace(saveData.data.test); // Test string
The idea is that initially you'll create all of the properties that you may want to save when the game launches for the first time:
And when you hit "save", overwrite these properties: