views:

332

answers:

2

Hi, I'm trying to modify Flash CS3's supplied fl.motion.easing.bounce function to make the resulting animation bounce less. I appreciate that 'bounce less' is a bit vague, but I'd appreciate any help in understanding the function.

Thanks.

 /**
 *  @param t Specifies the current time, between 0 and duration inclusive.
 *
 *  @param b Specifies the initial value of the animation property.
 *
 *  @param c Specifies the total change in the animation property.
 *
 *  @param d Specifies the duration of the motion.
 *
 *  @return The value of the interpolated property at the specified time.     
 */  
public static function easeOut(t:Number, b:Number,
                               c:Number, d:Number):Number
{
    if ((t /= d) < (1 / 2.75))
        return c * (7.5625 * t * t) + b;

    else if (t < (2 / 2.75))
        return c * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75) + b;

    else if (t < (2.5 / 2.75))
        return c * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375) + b;

    else
        return c * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375) + b;
}
A: 

Basically, the function returns an interpolated value for the new position depending on 4 factors: current time of animation, initial value of the property being animated, total change of the animation to be done, and the total duration of the animation.

What you have there is a check for different timings: if the animation still didn't reach aprox 36% (1 / 2.75) of total duration, apply the first ecuation; if it's between 36% and 72%, apply the second; etc.

Every ecuation is a function depending on the first tree arguments, so basically you need to tweak them a little bit.

I'd suggest playing with that hardcoded 7.5625 (make it greater and lower to see the results) until you're satisfied.

Seb
A: 

I know this is not going to give you a clear cut answer either but these equations where first conceived by Robert Penner in his book Programing Macromedia Flash MX. I know it's not an easy answer, but in his book he explains in detail how these functions work. To really understand you might want to pick up a copy and dig in.

Luke