Flex 4:无法为扩展Group的类的子类定义s:layout

1 apache-flex actionscript-3 flex4

我正在尝试通过在Flex 4中扩展Group来为组件创建基类,但我似乎无法通过MXML定义布局.每当我尝试将定义移动到我的基本组件的子类时,我都会收到以下错误:

Error: Could not resolve <s:layout> to a component implementation.
Run Code Online (Sandbox Code Playgroud)

从这个错误来看,似乎框架方面的一些魔法用于为一个组分配它,因此编译器在尝试为任何其他类分配它时失败.有谁知道这应该如何工作?知道如何允许我在子类中定义它吗?

Yve*_*ves 8

您必须使用子类的命名空间

代替

<s:layout>
Run Code Online (Sandbox Code Playgroud)

如果包/名称空间定义是customComp,例如use

<customComp:MyTestComponent id="aaa">
    <customComp:layout>
      <customComp:VerticalLayout />
    </customComp:layout>

    <Button id=.... />
    <Button id=.... />

</customComp:MyTestComponent>
Run Code Online (Sandbox Code Playgroud)