Apache flex mxml空引用

Apache flex mxml空引用,apache-flex,mxml,Apache Flex,Mxml,我有一个自定义mxml组件CustomRadio的示例 <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:RadioButton id="radio" /> <mx:Script> public override function set label(value:String):

我有一个自定义mxml组件CustomRadio的示例

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:RadioButton id="radio" />
    <mx:Script>
        public override function set label(value:String):void { 
            this.radio.label = value;
        }
        public override function get label():String {
            return this.radio.label;
        }
    </mx:Script>
</mx:VBox>

公共重写函数集标签(值:字符串):void{
this.radio.label=值;
}
公共重写函数get label():String{
返回此.radio.label;
}
和一个应用程序

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"  xmlns:local="*">
    <local:CustomRadio  label="xxx" />
</mx:WindowedApplication>


我得到集合标签上的空引用arror,表示这个。radio是空的。为什么?

RadioButton标签需要包含脚本标签。按照现在的方式,脚本标记只是VBox的一部分。因为您使用的是“this”指针,所以它指的是VBox

如果在使用值之前在“set”函数中设置断点(在其中放置跟踪或类似内容)-“this”指针中是否定义了单选按钮的任何部分?请尝试以下操作:->看起来您需要的是“super”而不是“this”