views:

34

answers:

1

Why this:

            for each (var dieListener:Object in dieListeners)
            {
                var f:Function = (dieListener as Function);
                f();
            }

..doesn't work, if this:

            for (var i:int=0; i<dieListeners.length; i++)
            {
                var f:Function = (dieListeners.getItemAt(i) as Function);
                f();
            }

..works!?

(the first one simply doesn't enter the for loop, but the second do!)

+1  A: 

ArrayList doesn't support for each. Try to use an ArrayCollection instead.

Claus Wahlers
Correct. The compiler should say something meaningful in cases like this.. Thanks!
Tom Brito