But you can already do that , instead of the "as" indicator , you just put it in the loop.
for each ( var displayObject:DisplayObject in array )
How would it come in handy , seeing as how its the same function ?
Yes, but you don't get the key-value pair, unless I am misunderstanding the FLEX functionality. In your example, does displayObject represent a key-value pair?
"for each" iterates through the objects in the arrray not the keys, so I don't think your example is correct.
To iterate through the keys, you need something like this:
for (var key:String in array)
trace("key '" + key + "' has the value '" + array[key].toString() + "'.");
Personally, I find the PHP style confusing.
1 person found this helpful
Personally , if I need the key-value paradigm, I use an object/hashmap , and iterate over its keys.
You're right ... see I still get confused by the difference to PHP and C++.
I did mean the example you describe. Thanks
I come from a C++ background, so I learned it that way from the start.
I'll mark this question off as answered -> a looping construct of this nature doesn't exist.