Guest User

Untitled

a guest
Jun 24th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. var newObj:Object = Object(ObjectUtil.copy(oldObj));
  2.  
  3. function clone(source:Object):* {
  4. var copier:ByteArray = new ByteArray();
  5. copier.writeObject(source);
  6. copier.position = 0;
  7. return(copier.readObject());
  8.  
  9. newObjectCopy = clone(originalObject);
  10.  
  11. // duplicate any given Object (not MCs)
  12. Object.prototype.copy = function()
  13. {
  14. ASSetPropFlags(Object.prototype,["copy"],1);
  15.  
  16. var _t = new this.__proto__.constructor(this) //
  17.  
  18. for(var i in this){
  19. _t[i] = this[i].copy()
  20. }
  21. return _t
  22. };
  23.  
  24. x = ["1","2","3",[4,5],[{a:1,b:2}]]
  25.  
  26. y = x.copy()
  27.  
  28. y[0] = 0
  29.  
  30. y[3][0]="d"
  31.  
  32. trace(x)
  33.  
  34. trace(y)
Add Comment
Please, Sign In to add comment