as3中,遍历class中所有的成员对象

2014-7-29 admin flash

as3中,遍历class中所有的成员对象
private static function parseObject(OBJ:Object):Object{
    var ret:Object = {};
    var xml:XML = describeType(OBJ);
    for(var i:int =0;i<xml.constant.length();i++){
        var name:String = xml.constant[i].@name;
        if( typeof(OBJ[name])=="object" ){
            var rv:Object = parseObject(OBJ[name]);
            for(var key:String in rv){
                ret[name+"."+key] = rv[key];
            }
        } else {
            ret[name] = OBJ[name];
        }
    }
    
    return ret;
}

标签: 算法 Flash

发表评论:

Powered by emlog | |

浙ICP备17021512号 |浙公网安备 33010602008237号