超类可以在哪个事件阶段引用其派生类中潜在的现有组件?

| 在Flex中,可以说我有一个超类...
class SuperComponent extends DragStack {

   private var _childReference:UIComponent;

   public function SuperComponent() {
      // ???
      addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
   }

   private function onCreationComplete(e:FlexEvent):void {
      //The \'this[]\' technique doesn\'t seem to work and causes run-time errors:
      //trace(\"Component found: \" + this[\"myButton\"]);
   }
}
然后,在我的应用程序中使用以下派生类(仅以一个模型MXML为例):
<!-- Component ChildComponent.mxml -->
<mx:SuperComponent>
  <mx:Button id=\"myButton\" label=\"Press Me!\" />
</mx:SuperComponent>
如何从SuperComponent类验证\“ myButton \”的存在并进行引用?我需要使用getChildByName(...)吗?     
已邀请:
        我不确定DragStack是什么类型的组件。它扩展了Container(Flex 3)还是Group(Flex4)?如果是这样,则该组件将经历其生命周期过程,并且在执行createChildren方法之后应该可以访问myButton。 我相信MXML在幕后做了一些魔术,以将按钮创建为组件的子级。 如果DragStack不是容器,则必须告诉我们DragStack的默认属性是什么。 DefaultProperty将在类元数据中指定。 我相信,如果未指定其他属性,则MXML基本上是将XML Children分配给SuperComponent类的默认属性。如果要将其分配给其他属性,则必须指定它,如下所示:
<mx:SuperComponent>
  <mx:myProperty>
  <mx:Button id=\"myButton\" label=\"Press Me!\" />
 </mx:myProperty>
</mx:SuperComponent>
通常仅在属性没有简单值的情况下使用此语法,例如DataGrid的列数组。     
        即使
myButton
是MXML中添加的那个容器的子级,也不能在容器中使用
this[\"myButton\"]
。 “ 4”仍然不是类属性,而是容器子元素的元素。 您最好使用
getChildByName()
传递
\"myButton\"
作为名称。     

要回复问题请先登录注册