var personTab:Object=new Object()
personTab.firstName='John'
personTab.lastName='Appleseed'
personTab.age=18
for(var A:String in personTab)
{
trace(A+': '+personTab[A])
}
Output order is lastName, firstName, age. What I don't understand is why it's not firstName, lastName, age. Also, if i change the name of the variable 'A' to say 'foo' the order changes to firstName, age, lastName.
最佳答案
ActionScript 中的对象是无序的,本质上您可以将它们视为哈希表或关联数组,其中的值由其键引用(请参阅 documentation )。如果顺序对您很重要,您应该使用数组,或者,如果您还需要能够通过键查找值,请创建您自己的保留顺序的自定义集合。
关于java - 为什么我的输出顺序看似随机( ActionScript 3.0)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13439886/