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 Back class defines three easing functions to implement 17 * motion with Flex effect classes. 18 * 19 * For more information, see http://www.robertpenner.com/profmx. 20 * 21 * @langversion 3.0 22 * @playerversion Flash 9 23 * @playerversion AIR 1.1 24 * @productversion Flex 3 25 */ 26public class Back 27{ 28 include "../../core/Version.as"; 29 30 //-------------------------------------------------------------------------- 31 // 32 // Class methods 33 // 34 //-------------------------------------------------------------------------- 35 36 /** 37 * The <code>easeIn()</code> method starts 38 * the motion by backtracking, 39 * then reversing direction and moving toward the target. 40 * 41 * @param t Specifies time. 42 * 43 * @param b Specifies the initial position of a component. 44 * 45 * @param c Specifies the total change in position of the component. 46 * 47 * @param d Specifies the duration of the effect, in milliseconds. 48 * 49 * @param s Specifies the amount of overshoot, where the higher the value, 50 * the greater the overshoot. 51 * 52 * @return Number corresponding to the position of the component. 53 * 54 * @langversion 3.0 55 * @playerversion Flash 9 56 * @playerversion AIR 1.1 57 * @productversion Flex 3 58 */ 59 public static function easeIn(t:Number, b:Number, c:Number, 60 d:Number, s:Number = 0):Number 61 { 62 if (!s) 63 s = 1.70158; 64 65 return c * (t /= d) * t * ((s + 1) * t - s) + b; 66 } 67 68 /** 69 * The <code>easeOut()</code> method starts the motion by 70 * moving towards the target, overshooting it slightly, 71 * and then reversing direction back toward the target. 72 * 73 * @param t Specifies time. 74 * 75 * @param b Specifies the initial position of a component. 76 * 77 * @param c Specifies the total change in position of the component. 78 * 79 * @param d Specifies the duration of the effect, in milliseconds. 80 * 81 * @param s Specifies the amount of overshoot, where the higher the value, 82 * the greater the overshoot. 83 * 84 * @return Number corresponding to the position of the component. 85 * 86 * @langversion 3.0 87 * @playerversion Flash 9 88 * @playerversion AIR 1.1 89 * @productversion Flex 3 90 */ 91 public static function easeOut(t:Number, b:Number, c:Number, 92 d:Number, s:Number = 0):Number 93 { 94 if (!s) 95 s = 1.70158; 96 97 return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b; 98 } 99 100 /** 101 * The <code>easeInOut()</code> method combines the motion 102 * of the <code>easeIn()</code> and <code>easeOut()</code> methods 103 * to start the motion by backtracking, then reversing direction and 104 * moving toward target, overshooting target slightly, reversing direction again, and 105 * then moving back toward the target. 106 * 107 * @param t Specifies time. 108 * 109 * @param b Specifies the initial position of a component. 110 * 111 * @param c Specifies the total change in position of the component. 112 * 113 * @param d Specifies the duration of the effect, in milliseconds. 114 * 115 * @param s Specifies the amount of overshoot, where the higher the value, 116 * the greater the overshoot. 117 * 118 * @return Number corresponding to the position of the component. 119 * 120 * @langversion 3.0 121 * @playerversion Flash 9 122 * @playerversion AIR 1.1 123 * @productversion Flex 3 124 */ 125 public static function easeInOut(t:Number, b:Number, c:Number, 126 d:Number, s:Number = 0):Number 127 { 128 if (!s) 129 s = 1.70158; 130 131 if ((t /= d / 2) < 1) 132 return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b; 133 134 return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b; 135 } 136} 137 138} 139