尝试更改Flex 3中的状态时出现异常

时间:2012-08-08 07:32:39

标签: actionscript-3 flex flex3

我试图通过点击按钮将舞台状态更改为不同的状态。问题是some times异常为The supplied DisplayObject must be child of the caller。 以下是我要改变状态的方法

this.currentState = 'fullScreen';

此处thiscanvas

以下是状态fullscreen

的MXML
<mx:State name="fullScreen">
            <mx:RemoveChild target="{lstExpert}"/>
            <mx:RemoveChild target="{screenToggle}"/>

            <mx:AddChild  relativeTo="{outContainer}" position="firstChild">
                <mx:HBox id="topHeaderBox" horizontalAlign="left" verticalAlign="middle" width="98.5%" height="60"/>
            </mx:AddChild>

            <mx:AddChild relativeTo="{topHeaderBox}" position="firstChild" >
                <mx:Label id="lblCourseName" width="100%"  text="Name" color="#ffffff" fontFamily="Arial" fontSize="14" fontWeight="bold" height="20" />    
            </mx:AddChild>

            <mx:AddChild target="{screenToggle}" relativeTo="{lblCourseName}" position="after" />



            <mx:AddChild relativeTo="message" position="before">
                <mx:Spacer id="Bar" height="5" width="2" />
            </mx:AddChild>
</state>

这里的错误是什么?

1 个答案:

答案 0 :(得分:0)

您可能希望绑定最后relativeTo个对象的AddChild属性值。意思是,这样写:

<mx:AddChild relativeTo="{message}" position="before">

假设您有一个具有该ID的元素。

希望这有帮助。