一聚教程网:一个值得你收藏的教程网站

热门教程

flash 引用与复制(ByteArray的拷贝方法)

时间:2022-07-02 17:16:00 编辑:袖梨 来源:一聚教程网

import flash.utils.ByteArray;

var myObj1:Object = new Object();
myObj1.nu = 10;
myObj1.nu2 = 16;

var myObj2:Object = new Object();
myObj2 = clone(myObj1);
myObj2.nu = 100;
myObj2.nu2 = 18;

trace("myObj2.nu: " + myObj2.nu);
trace("myObj2.nu2: " + myObj2.nu2);
trace("myObj1.nu: " + myObj1.nu);
trace("myObj1.nu2: " + myObj1.nu2);

function clone(obj:Object):* {
 var myBA:ByteArray = new ByteArray();
 myBA.writeObject(obj);
 myBA.position = 0;
 return (myBA.readObject());

}

热门栏目