【问题标题】:Exception on trying to change the state in Flex 3尝试在 Flex 3 中更改状态时出现异常
【发布时间】:2012-08-08 07:32:39
【问题描述】:

我正在尝试通过单击按钮将舞台状态更改为不同的状态。问题是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>

这里的错误是什么?

【问题讨论】:

  • 关于上下文的任何其他信息?例如,定义状态的 MXML 文件,或处理状态更改的 ActionScript 段。因为一个简单的任务不足以了解问题。
  • 编辑了问题,使用 MXML 表示新状态

标签: actionscript-3 apache-flex flex3


【解决方案1】:

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

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

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

希望这会有所帮助。

【讨论】:

  • 非常感谢您的回复,但这并不能解决问题,我应该在这里提到的另一件事是我在堆栈跟踪中看到了“firebug/getChild()”,不幸的是我无法复制它。打开firebug/flashbug会导致这个错误吗?
  • 我可以重现那个.. 在堆栈跟踪中我发现了一行在 import::FireBug/onAdded.. 请找到屏幕截图 (i1155.photobucket.com/albums/p559/veeru-as/Stateexception.png)
猜你喜欢
  • 1970-01-01
  • 2014-04-12
  • 1970-01-01
  • 1970-01-01
  • 2015-08-29
  • 1970-01-01
  • 2015-04-16
  • 2020-01-16
  • 1970-01-01
相关资源
最近更新 更多