AS3: Store array in shared object

情到浓时终转凉″ 提交于 2019-12-04 20:59:21

You should be able to do this,

To write to a shared object

//returns the mySharedObject if it exists, if not creates a new one
var so:SharedObject = SharedObject.getLocal("mySharedObject");
//take your array and put it on the so
so.data.storedArray = myArray;
//save the data
so.flush();

To read it back elsewhere

//get the mySharedObject back
var so:SharedObject = SharedObject.getLocal("mySharedObject");
//get your array back
myArray = so.data.storedArray;

I found something helpful that I'm going to add into the above code answer:

To read it back elsewhere

//get the mySharedObject back
var so:SharedObject = SharedObject.getLocal("mySharedObject","/");
//get your array back
myArray = so.data.storedArray;

To avoid inadvertently restricting access to a shared object, use the localpath parameter. - which is the "/"

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