1////////////////////////////////////////////////////////////////////////////////
2//
3//  ADOBE SYSTEMS INCORPORATED
4//  Copyright 2004-2007 Adobe Systems Incorporated
5//  All Rights Reserved.
6//
7//  NOTICE: Adobe permits you to use, modify, and distribute this file
8//  in accordance with the terms of the license agreement accompanying it.
9//
10////////////////////////////////////////////////////////////////////////////////
11
12package mx.effects.easing
13{
14
15/**
16 *  The Spark effects provided as of Flex 4 use classes which implement the
17 *  IEaser interface instead of the easing functions in classes like Quartic for
18 *  the earlier Flex 3 effects. To achieve the same functionality of Quartic,
19 *  create a Power instance with an <code>exponent</code> of 4 and set the
20 *  <code>easeInFraction</code> appropriately to get the desired result.
21 */
22[Alternative(replacement="spark.effects.easing.Power", since="4.0")]
23
24/**
25 *  The Quartic class defines three easing functions to implement
26 *  motion with Flex effect classes. The acceleration of motion for a Quartic easing
27 *  equation is greater than for a Quadratic or Cubic easing equation.
28 *
29 *  For more information, see http://www.robertpenner.com/profmx.
30 *
31 *  @langversion 3.0
32 *  @playerversion Flash 9
33 *  @playerversion AIR 1.1
34 *  @productversion Flex 3
35 */
36public class Quartic
37{
38    include "../../core/Version.as";
39
40    //--------------------------------------------------------------------------
41    //
42    //  Class methods
43    //
44    //--------------------------------------------------------------------------
45
46    /**
47     *  The <code>easeIn()</code> method starts motion from a zero velocity,
48     *  and then accelerates motion as it executes.
49     *
50     *  @param t Specifies time.
51     *
52     *  @param b Specifies the initial position of a component.
53     *
54     *  @param c Specifies the total change in position of the component.
55     *
56     *  @param d Specifies the duration of the effect, in milliseconds.
57     *
58     *  @return Number corresponding to the position of the component.
59     *
60     *  @langversion 3.0
61     *  @playerversion Flash 9
62     *  @playerversion AIR 1.1
63     *  @productversion Flex 3
64     */
65    public static function easeIn(t:Number, b:Number,
66                                  c:Number, d:Number):Number
67    {
68        return c * (t /= d) * t * t * t + b;
69    }
70
71    /**
72     *  The <code>easeOut()</code> method starts motion fast,
73     *  and then decelerates motion to a zero velocity.
74     *
75     *  @param t Specifies time.
76     *
77     *  @param b Specifies the initial position of a component.
78     *
79     *  @param c Specifies the total change in position of the component.
80     *
81     *  @param d Specifies the duration of the effect, in milliseconds.
82     *
83     *  @return Number corresponding to the position of the component.
84     *
85     *  @langversion 3.0
86     *  @playerversion Flash 9
87     *  @playerversion AIR 1.1
88     *  @productversion Flex 3
89     */
90    public static function easeOut(t:Number, b:Number,
91                                   c:Number, d:Number):Number
92    {
93        return -c * ((t = t / d - 1) * t * t * t - 1) + b;
94    }
95
96    /**
97     *  The <code>easeInOut()</code> method combines the motion
98     *  of the <code>easeIn()</code> and <code>easeOut()</code> methods
99     *  to start the motion from a zero velocity, accelerate motion,
100     *  then decelerate to a zero velocity.
101     *
102     *  @param t Specifies time.
103     *
104     *  @param b Specifies the initial position of a component.
105     *
106     *  @param c Specifies the total change in position of the component.
107     *
108     *  @param d Specifies the duration of the effect, in milliseconds.
109     *
110     *  @return Number corresponding to the position of the component.
111     *
112     *  @langversion 3.0
113     *  @playerversion Flash 9
114     *  @playerversion AIR 1.1
115     *  @productversion Flex 3
116     */
117    public static function easeInOut(t:Number, b:Number,
118                                     c:Number, d:Number):Number
119    {
120        if ((t /= d / 2) < 1)
121            return c / 2 * t * t * t * t + b;
122
123        return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
124    }
125}
126
127}
128