[ActionScript3.0] 深表复制

function clone(obj:Object):Object
{
  var byteArray:ByteArray = new ByteArray();
  byteArray.writeObject(obj);
  byteArray.position = 0;
  return byteArray.readObject();
}
var arr:Array = [1,2,3];
var arr1:Object = clone(arr);
var arr2:Array = arr;
arr.push(4);
trace(arr,arr1,arr2);
//1,2,3,4 1,2,3 1,2,3,4

------------------------------------------------------------------ Always put yourself in the other's shoes.If you feel that it hurts you,it probably hurts others,too.------------------------------------------------------------------
原文地址:https://www.cnblogs.com/frost-yen/p/4291988.html