Wednesday, January 27, 2010

Iteration over Arrays in ActionScript

I always need reminding that for each....in iterates over the values of an associative array:


for each (var value:* in object){
    trace(value);
}


...while for....in iterates over the keys of an associative array:

for (var key:String in object){
    trace(key + ": " + object[key]); // object[key] is value
}  

No comments:

Post a Comment