如何在 Actionscript 中获取对象的属性列表? [英] How can I get list of properties in an object in Actionscript?

查看:22
本文介绍了如何在 Actionscript 中获取对象的属性列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据提供程序和一个过滤器函数,用于分配给我的数据提供程序的数组.

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

如何在数据提供程序 (item.data) 传递给过滤器函数时获取其每一行中的属性列表?

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:

  • 对象
    • 姓名
    • 电子邮件
    • 地址

    然后我希望在我的过滤器功能中能够查看姓名、电子邮件和地址.不幸的是,我不知道这些属性会是什么.

    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.

    这篇关于如何在 Actionscript 中获取对象的属性列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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