继承UIComponent编写自定义控件Label不能展示

public class Td extends UIComponent
	{
		private var _label:Label;
		
		
		public function Td()
		{
		}
		
		override protected function createChildren():void{
			super.createChildren();
			
			if (!_label)
			{
				_label = new Label();				_
                                                                label.text="asdfasdfsd";
				addChild(DisplayObject(_label));
			}
		}
}

 代码如上时,界面上始终无法显示出label控件,改成如下代码即可

public class Td extends UIComponent
	{
		private var _label:IUITextField;
		
		
		public function Td()
		{
		}
		
		override protected function createChildren():void{
			super.createChildren();
			
			if (!_label)
			{
				_label = IUITextField(createInFontContext(UITextField));
				_label.text="asdfasdfsd";
				addChild(DisplayObject(_label));
			}
		}
}

 

具体原因暂不明白

你可能感兴趣的:(component)