2011-03-05 90 views
2

我目前對狀態變化使用柔性轉換效果。有沒有辦法可以使用tweenmax庫?flex使用tweenmax庫

更新:

在下面的代碼,我已經從一個國家到國家二級轉變。我想替換那個代碼tweenermax庫。

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" 
      currentState="NORMAL"> 
<s:states> 
    <s:State name="NORMAL" /> 
    <s:State name="CLICKED" /> 
</s:states> 
<fx:Script> 
    <![CDATA[ 
     import com.greensock.TweenMax; 

     public function init():void 
     { 
      currentState = "CLICKED"; 
      TweenMax.to(topbar, 10, {x:0, startAt:{x:-500}}); 
     } 
    ]]> 
</fx:Script> 

<s:layout> 
    <s:VerticalLayout paddingTop="5" paddingLeft="5" paddingRight="5"/> 
</s:layout> 

<s:BorderContainer id="topbar" height="30" width="100%" includeIn="CLICKED" > 
    <s:backgroundFill> 
     <s:SolidColor 
      color="#292929" 
      alpha="1"/> 
    </s:backgroundFill> 

</s:BorderContainer> 

<s:HGroup id="hg"> 
    <s:TextInput /> 
</s:HGroup> 
<s:Button click="init()" label="Click" /> 
</s:Application> 
+0

你需要更具體。舉一個你現在在做什麼的例子。顯示一些代碼。 – Scott 2011-03-05 23:11:37

+0

@Scott - 添加了代碼 – Nish 2011-03-06 03:18:15

+0

我的例子有幫助嗎?如果是的話,你可以接受答案。 – Scott 2011-03-22 06:00:45

回答

0

如果你不喜歡你的mxml變得太醜,你可以做幾件事。首先,您可以按照here所示的方式完成所有動作。正如你所提到的,TweenLite是另一種選擇。爲了在TweenLite中完成淡入淡出的效果,你可以選擇一個開始的alpha和結束alpha,以便對象從不透明轉換爲透明。

查看互動演示here。將alpha設置爲0並運行補間,你應該看到它消失。請記住,即使當你淡化某些東西時,它仍然在記憶中,並仍然在呈現。如果它佔用了合理數量的內存,並且不再需要它,請務必刪除它。