我怎样才能在ActionScript中的对象属性的列表?属性、对象、列表、ActionScript

2023-09-08 12:04:39 作者:我是少年我爱花菇凉°

我有一个数据提供器和我的阵列的filterFunction已分配给我的数据提供器。

I have a dataprovider and a filterfunction for my array that's assigned to my dataprovider.

我怎样才能得到属于数据提供器(item.data)的每一行中,因为它被传递到的filterFunction属性的列表?

How can I get a list of the properties that are in each row of the dataprovider (item.data) as it gets passed to the filterfunction?

例如,如果我的对象包含:

For instance, if my object contained:

对象 名称 电子邮件 地址 Object name email address

然后我想,在我的filterFunction才能够看的姓名,电子邮件和地址。不幸的是,我不知道这些属性将是前手。

Then I would want, in my filterfunction to be able to look at name, email and address. Unfortunately, I don't know what these properties will be before hand.

任何想法?

推荐答案

如果它是一个动态的对象,我相信你可以做这样的事情:

If it's a dynamic object I believe you can just do something like this:

var obj:Object; // I'm assuming this is your object

for(var id:String in obj) {
  var value:Object = obj[id];

  trace(id + " = " + value);
}

这就是它是如何在AS2做的,我相信仍然可以工作在AS3动态对象。我认为,这将显示性能是在非动态对象更加有限。

That's how it's done in AS2, and I believe that still works for dynamic objects in AS3. I think the properties that it will show is more limited on non-dynamic objects.