// 也就是說,你不一定直接用 shared object 的 data 下的屬性來改值,可以把 reference 傳給其他 function 後,讓那些 function 自己改
var bytes:ByteArray = new ByteArray();
var example:SharedObject = SharedObject.getLocal( "example8");
var tempList:Array;
var targetObject:Object;
function Target(
o:Object ) {
targetObject = o; targetObject.times = 10;
}
function AddTarget() {
targetObject.times++;
}
if ( example.data.times == undefined ) {
example.data.times = new Number();
var i:Number;
i = 0;
example.data.times = i;
trace("i:" + i); // first time, 0
trace("Before Target():" + example.data.times);// first time, 0
Target( example.data ); trace("After Target():" + example.data.times);//
first time, 10 AddTarget();
AddTarget();
AddTarget();
AddTarget();
AddTarget(); trace("After 5 AddTarget():" + example.data.times);//
first time, 15 example.flush();
}
else{
trace("example.data.times last time:" + example.data.times); // from the second time, 15
}