2011-11-03 4 views
0

나는 Flex 4.5를 사용하여 간단한 사용자 인터페이스를 프로그래밍합니다.변경 탄성 속성

애니메이션, 특히 탄성 (spark.effects.easing.Elastic) 팝업 애니메이션을 추가하고 싶습니다.

탄성 애니메이션의 속성을 변경하는 방법이 있습니까? 그것은 너무 많이 앞뒤로 반송, 그 행동을 변경하거나 내가 필요로하는 옵션을 제공하는 다른 easing 애니메이션을 사용하여 그 행동을 모방하는 방법이 있습니까?

예제 코드에서 찾을 수 있습니다

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/effects/easing/Elastic.html

감사

당신은 다음과 같은 몇 가지 더 사용자 정의 변수를 노출 스파크 탄성 쉽게 클래스를 서브 클래 싱 할 수

답변

1

:

package 
{ 
    import mx.effects.easing.Elastic; 
    import spark.effects.easing.Elastic; 

    /** Expose some properties on the spark Elastic easer */ 
    public class MyElastic extends spark.effects.easing.Elastic 
    { 
     /** 
     * (Copied from the ASDoc for mx.effects.easing.Elastic.easeout()): 
     * @param b Specifies the initial position of a component. 
     * @param c Specifies the total change in position of the component. 
     * @param d Specifies the duration of the effect, in milliseconds. 
     * @param a Specifies the amplitude of the sine wave. 
     * @param p Specifies the period of the sine wave. 
     */ 
     public var b:Number = 0; 
     public var c:Number = 1; 
     public var d:Number = 1; 
     public var a:Number = 0; 
     public var p:Number = 0; 

     override public function ease(fraction:Number):Number 
     { 
      return mx.effects.easing.Elastic.easeOut(fraction, b, c, d, a, p); 

      // if these properties aren't enough control then you can copy and paste 
      // the code from mx.effects.easing.Ellastic.easeOut() directly into this 
      // overridden method and tweak the code for your needs from there. 
     } 
    } 
} 

이러한 변수가 찾고있는 컨트롤을 제공하지 않으면 mx.effects.eas의 코드를 복사하여 붙여 넣기 만하면됩니다. ing.Ellastic.easeOut()을 MyElastic.ease()에 추가하고 거기에서해야 할 조정을 완벽하게 제어 할 수 있습니다.

다음은이 서브 클래스 보여주는 간단한 예제 응용 프로그램입니다 :

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         xmlns:local="*"> 

    <s:Button click="mover.play()" label="move" x="100" y="50" /> 

    <s:Button id="btn" y="100" x="50" /> 
    <s:Button id="btn2" y="150" x="50" /> 

    <fx:Declarations> 
     <s:Parallel id="mover"> 
      <s:Move target="{btn}" xBy="100"> 
       <s:easer> 
        <s:Elastic /> 
       </s:easer> 
      </s:Move> 
      <s:Move target="{btn2}" xBy="100"> 
       <s:easer> 
        <local:MyElastic a="3" /> 
       </s:easer> 
      </s:Move> 
     </s:Parallel> 
    </fx:Declarations> 

</s:WindowedApplication> 
+0

당신에게 너무 많은 감사를! :) – ufk