Apache flex 更改弹性属性

Apache flex 更改弹性属性,apache-flex,animation,flex4.5,easing,Apache Flex,Animation,Flex4.5,Easing,我使用Flex4.5编写了一个简单的用户界面 我想添加弹出式的放松动画,特别是弹性动画(spark.effects.easing.Elastic) 有没有办法更改弹性动画的属性?它来回反弹太多了,有没有办法改变这种行为,或者使用其他提供我所需选项的缓和动画来模拟这种行为 示例代码可在以下位置找到: 谢谢您可以对spark Elastic ease类进行子类化,以公开更多的定制变量,如下所示: package { import mx.effects.easing.Elastic;

我使用Flex4.5编写了一个简单的用户界面

我想添加弹出式的放松动画,特别是弹性动画(spark.effects.easing.Elastic)

有没有办法更改弹性动画的属性?它来回反弹太多了,有没有办法改变这种行为,或者使用其他提供我所需选项的缓和动画来模拟这种行为

示例代码可在以下位置找到:


谢谢

您可以对spark Elastic ease类进行子类化,以公开更多的定制变量,如下所示:

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.easing.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>