I was just tinkering and wondered what would be quicker, using clone() on a Rectangle or just copying each property by hand.Totally blown away by the difference,
import flash.utils.getTimer;import flash.geom.Rectangle;var time:Number = getTimer();function runClone():void{ var rect:Rectangle=new Rectangle(0,0,100,100); var destRect:Rectangle=rect.clone(); time = getTimer(); for (var i:int = 0; i < 10000000; i++) { destRect=rect.clone(); } trace("runClone: ", (getTimer()-time));}function runCopy():void{ var rect:Rectangle=new Rectangle(0,0,100,100); var destRect:Rectangle=rect.clone(); time = getTimer(); for (var i:int = 0; i < 10000000; i++) { destRect.x=rect.x; destRect.y=rect.y; destRect.width=rect.width; destRect.height=rect.height; } trace("runCopy: ", (getTimer()-time));}runClone();runCopy();
And here's my results ( Please feel free to post your own, or to point out anything dumb I may have done to affect the outcome )
runClone: 11567runCopy: 65
Squize.
Powered by: newtelligence dasBlog 1.9.6264.0
Disclaimer The opinions expressed herein are our personal opinions and do not represent our customer's view in anyway.
© Copyright 2009, gaming your way
E-mail