Notes
The new for Each ... In addition to traversing XML, can also be used to traverse arrays and objects. Create "Million Xiong":
var testarr:array = new Array ();
for (var i:number = 0; i < 1000000; i++)
{
Testarr.push (i);
}
Previous for and for ... in and new for Each ... in loop:
For 260 milliseconds
var len:number = testarr.length;
for (var j:number = 0; J < Len; j + +)
{
testarr[j]++;
}
For ... in 8000 milliseconds
for (Var k:string in Testarr)
{
testarr[k]++;
}
For each ... in 58 milliseconds
For each (Var m:number in Testarr)
{
m++;
}
What about efficiency? After several tests, the for loop averaged 260 milliseconds (an average of 400 milliseconds without an array length), the for ... in loop averaged 8000 milliseconds, for each ... in loop 58 milliseconds!! So you should try to avoid for ... in, use for each ... in, with a for loop the best stored array length (var len:number = testarr.length;).
The case of object, for ... in an average of 560 milliseconds, for each ... in an average of 8 milliseconds.
var testobj:object = new Object ();
for (var i:number = 0; i < 100000; i++)
{
Testobj[i] = i + 1;
}
For ... in Read tab 560 MS
for (Var j:string in testobj)
{
testobj[j]++;
}
For each ... in direct read value 8 milliseconds
For each (Var k:number in testobj)
{
k++;
}
Small series of words: Or that sentence, we are not everyone can understand the flex so, but each of us can do a little bit of interest for our efforts. As long as your one click, a message can give the author more power. International...... Collective to fool the nest of the words of irrigation.