I use shared objects a lot and I've run into a problem. When saving an array
into a local shared object, if the array is changed, it automatically changes
in the shared object when the swf is exited. For example:
// ----- create a shared object ----- //
var cSaved:SharedObject = SharedObject.getLocal("test","/");
// ----- create an object, an array, and a numeric variable ----- //
var anobject:Object = new Object();
anobject.aname = "bob";
var anarray:Array = new Array(0,1,2,3,4);
var anum:Number = 100;
// ----- save this info to the shared object ----- //
cSaved.data.thisobject = anobject;
cSaved.data.thisnum = anum;
cSaved.data.thisarray = anarray;
cSaved.flush();
// ----- change the values of the variables ----- //
anobject.aname = "willie";
anum = 50;
anarray[3] = 100;
// ----- check the values in the shared object. They changed! ----- //
trace(cSaved.data.thisobject.aname);
trace(cSaved.data.thisarray);
stop()
In the above code, when I changed the value of anarray[3] to 100, it
automatically changed the value of cSaved.data.thisarray. However, changing
the value of anum does NOT change the value of cSaved.data.thisnum when exiting
the swf.
Is there a way to stop arrays saved in a shared object from updating like
this? It does it with objects too. Thanks.
-Glenn-
// ----- create a shared object ----- //
var cSaved:SharedObject = SharedObject.getLocal("test","/");
// ----- create an object, an array, and a numeric variable ----- //
var anobject:Object = new Object();
anobject.aname = "bob";
var anarray:Array = new Array(0,1,2,3,4);
var anum:Number = 100;
// ----- save this info to the shared object ----- //
cSaved.data.thisobject = anobject;
cSaved.data.thisnum = anum;
cSaved.data.thisarray = anarray;
cSaved.flush();
// ----- change the values of the variables ----- //
anobject.aname = "willie";
anum = 50;
anarray[3] = 100;
trace(cSaved.data.thisobject.aname);
trace(cSaved.data.thisarray);
stop()