2015-07-10 52 views
1

我試圖在發送請求時爲圖像添加動畫,然後在收到響應時停止旋轉該圖像,但我在動畫方面遇到了問題。你會如何編寫一個效果連續旋轉圖像?

這是我到目前爲止有:

<s:Sequence id="requestAnimation" repeatCount="0"> 
     <s:Parallel> 
      <s:Fade alphaFrom="1" alphaTo="0" target="{busyLogo}" duration="250" /> 
      <s:Fade alphaFrom="0" alphaTo="1" target="{cornerLogo}" duration="250" /> 
     </s:Parallel> 
     <s:Sequence repeatCount="0"> 
      <s:Rotate3D angleZFrom="0" 
         angleZTo="360" 
         autoCenterProjection="true" 
         autoCenterTransform="true" 
         duration="1000" 
         target="{busyLogo}" /> 
     </s:Sequence> 
    </s:Sequence> 

圖像旋轉,當它到達一個完整的旋轉到底是減速至停止,然後重新啓動。我希望它在一個連續的循環中旋轉。

回答

0

設置Rotate3D效果中使用的easer。默認值是正弦,這導致減速和加速。如果您想使其保持不變,請將其更改爲spark.effects.easing.Linear

+0

這隻會導致它播放一次。我希望圖像無限期旋轉。 –

+0

我猜錯了你的問題。我上面的回答已被更正。 –

+0

謝謝我將Linear easer添加到效果中。 –

1

首先,我想知道你的busyLogo如何在這個代碼中旋轉,因爲在主序列中,你首先在busyLogo上淡出alpha,並在cornerLogo中淡出。它應該是相反的 - 你應該淡入busyLogo然後旋轉它?

但主要問題似乎是無限期地播放整個序列(淡出和旋轉)的主序列上的repeatCount =「0」。如果刪除主序列上的repeatCount =「0」,它將淡出,然後在第二個序列處停止,該序列將無限次旋轉徽標,並顯示它的repeatCount =「0」

確保您一旦停止了這兩個序列是爲了避免內存泄漏。

+0

我注意到我回去工作之後。我刪除了淡出,並將動畫分成兩個獨立的序列。它似乎在工作(交叉手指)。 –

0

我現在有以下幾點。這似乎工作,但動畫並不像我希望的那樣流暢。可能試着做一個發佈版本,看看是否更好,或者增加圖像的平滑度。

<s:Parallel id="requestAnimation" > 
     <s:Fade alphaFrom="0" alphaTo="1" target="{busyLogo}" duration="250" /> 
     <s:Sequence suspendBackgroundProcessing="true" repeatCount="0"> 
      <s:Rotate3D angleZFrom="0" 
         angleZTo="360" 
         easer="{new Linear(0,0)}" 
         autoCenterProjection="true" 
         autoCenterTransform="true" 
         duration="1000" 
         target="{busyLogo}" /> 
     </s:Sequence> 
    </s:Parallel> 


    <s:Sequence id="fadeOutRequest" effectEnd="requestAnimation.end()"> 
     <mx:AnimateProperty property="alpha" fromValue="1" toValue="0" target="{busyLogo}" duration="1050" /> 
    </s:Sequence> 

    <s:Image id="mainLogo" x="0" y="0" width="128" height="128" source="{logo256}" 
      rollOver="{requestAnimation.play()}" rollOut="{fadeOutRequest.play()}" 
      alpha="0"/> 
    <s:BitmapImage id="logo4" x="32" y="32" source="{logo64}"/>