0 0

Flex4 通过反射MXML,获取MXML组件中的button信息,获取的信息为null5

想通过Flex反射mxml获取组件中的自定义button信息。但是获取的button为null,但是可以获取public的属性信息。代码如下:
var _PurviewButtons:Boolean = true;
try {
trace("实例化:"+item.@type);
var _PurviewRefrence:Class = getDefinitionByName(item.@type) as Class;
}
catch(e:ReferenceError) {
_PurviewButtons = false;
trace(e);
//continue;
}
if(_PurviewButtons){
var _PurviewInstance:UIComponent = new _PurviewRefrence() as UIComponent;

var propertiesList:XMLList = describeType(_PurviewInstance).accessor.(@type=="com.fms.xx.module::PurviewButton");

for each(var propertyInfoa:XML in propertiesList){

var propertyNamea:String = propertyInfoa.@name;
trace("propertyNamea  "+propertyNamea +"  "+_PurviewInstance[propertyNamea]);
}

var _PurviewInstanceInfo:XML=describeType(_PurviewInstance);
var _properties:XMLList=_PurviewInstanceInfo..accessor.(@type=="com.fms.xx.module::PurviewButton");
trace("_properties:"+_properties.toXMLString());
//遍历按钮
for each(var _propertyInfo:XML in _properties){       
var _propertyName:String = _propertyInfo.@name;//此处取出的为id
if(_PurviewInstance[_propertyName]!=null){
var _btnLabel:String = Button(_PurviewInstance[_propertyName]).label; //显示出来的按钮名称

//创建叶子节点--按钮节点
var _menuButton:Object = new Object();
_menuButton.id = _propertyName;
_menuButton.label = _btnLabel;
_menuButton.selected = false;
_menuButton.value = _propertyName;

//把按钮节点放入菜单项节点的子节点数组中
menuLeaf.children.push(_menuButton);
}else{
trace("按钮名称:"+_propertyName+" 为null。。。");
}

} //end of for
}
在mxml上端已经声明需要反射的mxml对象。
这个问题如何解决
2014年3月12日 09:06
目前还没有答案

相关推荐

Global site tag (gtag.js) - Google Analytics