2012-08-08 49 views
0

我試圖通過單擊按鈕將舞臺狀態更改爲不同狀態。問題是some times我得到例外The supplied DisplayObject must be child of the caller。 這裏是我試圖做些什麼來改變狀態嘗試更改Flex 3中狀態的例外情況

this.currentState = 'fullScreen'; 

這裏thiscanvas

這裏是國家fullscreen

<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?

+0

關於上下文的任何其他信息?例如定義狀態的MXML文件或處理狀態更改的ActionScript段。因爲簡單的分配不足以讓人感覺到問題。 – 2012-08-08 07:52:41

+0

編輯這個問題,MXML爲新狀態 – 2012-08-08 09:22:16

回答

0

您可能想要綁定最後一個AddChild對象的relativeTo屬性值。意思是這樣寫的:

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

假設你有一個具有該id的元素。

希望這會有所幫助。

+0

非常感謝您的回覆,但是這並不能解決問題,還有一件事我應該在這裏提到,我在堆棧跟蹤中看到了'firebug/getChild()',不幸的是我無法複製。打開螢火蟲/閃光燈會導致這個錯誤? – 2012-08-08 11:37:57

+0

我可以重現..在堆棧跟蹤中,我發現一條線在導入:: FireBug/onAdded ..請找到屏幕截圖(http://i1155.photobucket.com/albums/p559/veeru-as/Stateexception巴紐) – 2012-08-08 11:53:21

相關問題