通过ActionScript对象属性名称循环 [英] looping through object property names in actionscript

查看:114
本文介绍了通过ActionScript对象属性名称循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我创建了一个动态类

I have a dynamic class that I have created

public dynamic class SiteZoneFileUploadVO
{       
    public var destination:String = "sitezone";
    public var siteZoneId:uint;
    public var fileType:String;
    public var fileContents:String;

    public function SiteZoneFileUploadVO()
    {
    }

}

当我尝试遍历这个对象的属性名只迭代动态添加的属性。

when I try to iterate over this object's property names it only iterates the dynamically added properties.

        parameters.dynVar= "value";

        for(var name:String in parameters) 
        {
            trace(name);
        }

即使对象都等于一个值(IVE在调试器中检查这一点)唯一的属性名将追查是dynVar。属性

Even though the object has all the properties equal to a value (ive checked this in the debugger) the only property name that will be traced is dynVar.

我如何能遍历所有的属性名并不仅仅是动态添加的呢?

How can I iterate over all the property names and not just the dynamically added ones?

推荐答案

您可以使用的 不如describeType() 以获取XML与你的类的所有方法和变量,然后筛选出的属性您要遍历(如所有变量),并将其存储在一个的XMLList

作为下一步你会再遍历的XMLList 并用方括号你的对象由他们的名字来访问过滤性能。但是,你只能访问公共属性这种方式,因为不如describeType()不会看私有属性。

As the next step you would then iterate over the XMLList and use square bracket notation on your object to access the filtered properties by their names. However, you can only access public properties this way because describeType() won't look at private properties.

这篇关于通过ActionScript对象属性名称循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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