Actionscript 3 saving currentframe location to local hard drive?

淺唱寂寞╮ 提交于 2019-12-02 16:38:20

问题


I asked similar question sometime ago, but I am making new one to be much more specific with my question with some example!

I´ve found this code snippet/tutorial from googling, but I cant seem to figure out how to modify it for my needs:

// open a local shared object called "myStuff", if there is no such object - create a new one
var savedstuff:SharedObject = SharedObject.getLocal("myStuff");
// manage buttons
btnSave.addEventListener(MouseEvent.CLICK, SaveData);
btnLoad.addEventListener(MouseEvent.CLICK, LoadData);

function SaveData(MouseEvent){
 savedstuff.data.username = nameField.text // changes var username in sharedobject
 savedstuff.flush(); // saves data on hard drive
 }
function LoadData(MouseEvent){
 if(savedstuff.size>0){ // checks if there is something saved
 nameField.text = savedstuff.data.username} // change field text to username variable
 }

// if something was saved before, show it on start
if(savedstuff.size>0){
nameField.text = savedstuff.data.username}

So what I am trying to figure out how to do, is to save users current frame to local hard drive, as my flash progress is based on frame location. yeah, so how do I modify it so that it stores data of current frame? and how about current frame inside movieclip, if that is makes things different?

help MUUUCH appreciated! thanks!


回答1:


In your example it looks like it is already saving something to the shared object:

savedstuff.data.username = nameField.text;

Just replace it with the movie clip frame value instead (and probably under a different property name other then "username").

Then on load, there is another line where it loads the data:

nameField.text = savedstuff.data.username;

It would be the same way, except replace "username" with whatever property name you choose. Then you may have to parse into an int again and use it to restore progress however way you have it set up.



来源:https://stackoverflow.com/questions/13413027/actionscript-3-saving-currentframe-location-to-local-hard-drive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!