2011-09-26 117 views
0

嗨,大家好我的問題是,當我在狀態1中創建一個按鈕,並根據代碼點擊它,它應該在另一個名爲expand的狀態下創建一個組。但是根據我的代碼,它仍然在當前狀態下進行組合。任何指導都將不勝感激。更改視圖狀態

   mybutton.addEventListener(MouseEvent.CLICK, max); 

public function max(event:MouseEvent):void 
      { 
       currentState = 'expand'; 
       var s:String; 
       s = "abc"; 
       var myGroup:Group = new Group(); 
       myGroup.id = s; 
       addElement (myGroup); 
       container_Class2(myGroup); 

      } 
+0

的addElement(爲myGroup)將於VisualElement添加到視圖無論哪種狀態,它都將在所有狀態中顯示。 –

回答

0

currentState僅僅是一個類的屬性,有沒有這樣的事情「創建的狀態的東西」。如果你將一個元素添加到你的類中,它將存在於任何狀態。

您可以創建一個元素作爲容器的孩子只出現在特定的狀態:

<s:Group id="expandContainer" includeIn="expand" /> 

...

expandContainer.addElement(myGroup);