这段代码有效,但是当我把loadBtn和函数'loadNames'放在另一个swf文件中时,程序会跟踪这个:“保存名称:undefined”,另外我想指定保存对象的路径:我怎么能这样做?
var SO:SharedObject=SharedObject.getLocal("mySave");
var archive:Array=new Array();
var counter:Number=-1;
saveBtn.addEventListener(MouseEvent.CLICK, saveName);
loadBtn.addEventListener(MouseEvent.CLICK, loadNames);
function saveName(event:Event) {
counter++;
archive[counter]=input.text;
SO.data.arrSaved=archive;
SO.flush();
}
function loadNames(event:Event) {
trace("saved names: "+SO.data.arrSaved);
}