2010-07-05 61 views
0

我想做一個簡單的動畫。我想淡入並在creationcomplete內調整List的大小。我的問題是我可以在元素動畫開始之前總是看到元素閃爍。換句話說,用戶會看到該元素出現1秒 - >然後淡入並調整動畫大小。我希望這裏有人能幫我解決這個問題。謝謝...Flex動畫問題

我的代碼。

AS:

protected function compList_creationCompleteHandler(event:FlexEvent):void 
{ 

    compinfoResult.token = getCompList.compinfo(); 
    compinfoResult.addEventListener(ResultEvent.RESULT, completeLoading); 

    function completeLoading(event:ResultEvent):void{ 

    fadeList.play(); //the animation will fire when the List get the result from the server... 
    scaleList.play(); 

} 
} 

mxml 


    <s:Scale id="scaleList" scaleXFrom="0" scaleXTo="1" scaleYFrom="0" 
    scaleYTo="1" duration="500" target="{compList}" /> 
    <s:Fade id="fadeList" alphaFrom="0" alphaTo="1" target="{compList}" /> 


    <s:List id="compList" 
    width="280" 
    height="560" 
    x="0" 
    y="0" 
    alpha="0" 
    creationComplete="compList_creationCompleteHandler(event)" 
    itemRenderer="itemRenderer.compListItemRenderer" 
    change="compList_changeHandler(event)"/> 

回答

1

首先,我將這些組合成一個單一的轉變,無論是在平行或順序在您的喜好:

<s:Sequence id="effectSequence"> 
    <s:Scale id="scaleList" scaleXFrom="0" scaleXTo="1" scaleYFrom="0" 
scaleYTo="1" duration="500" target="{compList}" /> 
    <s:Fade id="fadeList" alphaFrom="0" alphaTo="1" target="{compList}" /> 
</s:Sequence> 

然後,我不會試圖觸發這與一個事件手動。使用效果,在這種情況下,我建議creationCompleteEffect

<s:List id="compList" 
    width="280" 
    height="560" 
    x="0" 
    y="0" 
    alpha="0" 
    creationComplete="compList_creationCompleteHandler(event)" 
    itemRenderer="itemRenderer.compListItemRenderer" 
    change="compList_changeHandler(event)" 
    creationCompleteEffect="{effectSequence}"`/> 
+0

不錯..謝謝很多。這就是我需要..:D – FlyingCat 2010-07-05 23:14:24

+0

很高興能夠幫助! – JeffryHouser 2010-07-05 23:17:05