订单的产品在ActionScript对象 [英] Order of items in objects in ActionScript

查看:122
本文介绍了订单的产品在ActionScript对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试编译:

var object:Object = {};

object.one = "foo";
object.two = "foo";
object.three = "foo";
object.four = "foo";

for(var key:String in object)
{
    trace(key);
}

...您将获得:

... you will get:

one
four
two
three

为什么搞砸了订单?

Why the messed up order?

推荐答案

对象的键没有顺序。如果您需要preserve秩序,有查找,那么你需要创建一个自定义集合,提供了该功能。

The keys of an object are not ordered. If you need to preserve order and have a lookup, then you need to create a custom collection that provides that functionality.

这篇关于订单的产品在ActionScript对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆