Revised AS3 loop comparison table
November 13, 2006 on 4:42 pm | In Actionscript | 2 CommentsI have just noticed that besides the for..in syntax there is a new syntax in AS3:
for each (i in object)
{
val = i;
}
For some reason this is a lot faster than the old syntax – it is still slower than the fastest integer loop, but this shouldn’t affect the performance very much. Better read the manual next time ;-)
I also have updated the performance table in the previous post.
I think you made a mistake with the example of your code:
var i:String;
var val:*;
for (i in obj)
{
val = obj[i];
};
vs.
var i:*;
var val:*;
for each (i in obj)
{
val = i;
};
Greetz Erik
Comment by EECOLOR — November, 30 2006 #
thank you for pointing this out, I have corrected the line :-)
Comment by mike — December, 2 2006 #