For-Each Loop AS3: Is the direction guaranteed?

前端 未结 3 659
暗喜
暗喜 2020-12-11 15:33

I would like to know the iteration order for the Array, Dictionary and Object types in AS3, for both the for-each and the for-in loops. Also what factors can change the iter

3条回答
  •  暖寄归人
    2020-12-11 16:17

    As stated in Essential Actionscript 3.0 by Colin Moock, the order of a for each in loop is not guaranteed unless enumerating an XML or XMLList object;

    Click here for Colin Moock's words from his book.

    There are workarounds as discussed here, but honestly if you need to guarantee the order then just use a regular old for loop and have it iterate (length, numChildren, etc.) number of times.

提交回复
热议问题