изменить эластичные атрибуты - PullRequest
0 голосов
/ 03 ноября 2011

Я использую Flex 4.5 для программирования простого пользовательского интерфейса.

Я хочу добавить всплывающие окна, замедляющие анимацию, особенно Elastic (spark.effects.easing.Elastic).

Есть лиспособ изменить атрибут эластичной анимации?он слишком сильно подпрыгивает туда-сюда, есть ли способ изменить это поведение или имитировать это поведение, используя некоторую другую анимацию замедления, которая предоставляет нужные мне опции?

Пример кода можно найти по адресу:

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

спасибо

1 Ответ

1 голос
/ 06 ноября 2011

Вы можете создать подкласс класса Spark Elastic Easy, чтобы представить еще пару переменных настройки, таких как:

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