Student
Student

Reputation: 28345

ActionScript beginner, understanding for-each

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!)

Upvotes: 0

Views: 996

Answers (1)

Claus Wahlers
Claus Wahlers

Reputation: 1231

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

Upvotes: 7

Related Questions