我有一個BaseComponentClass,我用作所有我的自定義組件擴展的類。 出於某種原因,我的自定義組件在運行時不顯示。我沒有收到任何編譯或運行時錯誤。 我正在實施所有受保護的UIComponent方法。 我的代碼如下所示:UIComponent基類不工作
public class BaseComponentClass extends UIComponent
{
public function BaseComponentClass()
{
super();
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
}
override protected function createChildren():void
{
super.createChildren();
for (var i:uint=0; i < super.numChildren; i++)
{
var childObj:DisplayObject = super.getChildAt(i);
addChild(childObj);
}
}
override protected function commitProperties():void
{
super.commitProperties();
}
override protected function measure():void
{
super.measure();
}
}
然後,我用它作爲基類在我的MXML自定義組件有點像這樣:
<local:BaseComponentClass xmlns:local="local.com.*" xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Button id="btn" label="My Button" />
</local:BaseComponentClass>
的按鈕從不在運行時顯示出來。
如果您不覆蓋受保護的方法(因爲您目前沒有在其中做任何額外的工作)會發生什麼? – 2010-01-05 00:04:11
什麼都沒有發生。我上面描述的問題仍然存在。 – CodeQrius 2010-01-05 00:10:39