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: 11567
runCopy: 65
Squize.