Advertisement
Guest User

as3 array vector splice test

a guest
Dec 6th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import flash.events.Event;
  2. import flash.utils.getTimer;
  3. import flash.display.Sprite;
  4.  
  5. var av:Vector.<Sprite> = new <Sprite>[this, this, this,this];
  6. var bv:Vector.<Sprite> = new <Sprite>[];
  7.  
  8. var aa:Array = [this, this, this,this];
  9. var ba:Array = [];
  10.  
  11. for (var i=0; i < 1E7; i++) {
  12.     ba.push(this);
  13.     bv.push(this);
  14. }
  15.  
  16. var index:int = 2;
  17.  
  18. super.addEventListener(Event.ENTER_FRAME, test);
  19.  
  20. function test(e:Event):void {
  21.     var t1:int = getTimer();
  22.     aa.splice(index, 2, aa[index + 1], aa[index]);
  23.     var t2:int = getTimer();
  24.     ba.splice(index, 2, ba[index + 1], ba[index]);
  25.     trace(t2-t1, getTimer()-t2);
  26.    
  27.     t1 = getTimer();
  28.     av.splice(index, 2, av[index + 1], av[index]);
  29.     t2 = getTimer();
  30.     bv.splice(index, 2, bv[index + 1], bv[index]);
  31.     trace(t2-t1, getTimer()-t2);
  32.     trace('-');
  33.    
  34. }
  35.  
  36. /**
  37. 0 6
  38. 0 0
  39. -
  40. 0 6
  41. 0 0
  42. -
  43. 0 6
  44. 0 0
  45. -
  46. 0 7
  47. 0 0
  48. -
  49. 0 6
  50. 0 0
  51. -
  52. 0 7
  53. 0 0
  54. -
  55. 0 7
  56. 0 0
  57. -
  58. 0 6
  59. 0 0
  60. -
  61. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement