Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var newObj:Object = Object(ObjectUtil.copy(oldObj));
- function clone(source:Object):* {
- var copier:ByteArray = new ByteArray();
- copier.writeObject(source);
- copier.position = 0;
- return(copier.readObject());
- newObjectCopy = clone(originalObject);
- // duplicate any given Object (not MCs)
- Object.prototype.copy = function()
- {
- ASSetPropFlags(Object.prototype,["copy"],1);
- var _t = new this.__proto__.constructor(this) //
- for(var i in this){
- _t[i] = this[i].copy()
- }
- return _t
- };
- x = ["1","2","3",[4,5],[{a:1,b:2}]]
- y = x.copy()
- y[0] = 0
- y[3][0]="d"
- trace(x)
- trace(y)
Add Comment
Please, Sign In to add comment