Jump to content
Search Community

Flash IDE classic tween ease

reinierf test
Moderator Tag

Recommended Posts

Hi all,

 

Here is an ease class that exactly replicates the Flash IDE classic tween easing (where you can enter a value in the range -100..100 for a timeline ease).

A customer of mine wanted to be able to use the values he always worked with so I replicated the ease function used in the Flash IDE.

Use it as you like. Create a file for the code and place it in com.greensock.easing.

 

Usage example :

TweenLite.to(mc, 2, {x:100, ease:ClassicEase.ease, easeParams:[50]});

This will tween the mc.x property to 100 with an classic tween ease of value 50.

 

package com.greensock.easing
{
/**
 * Class containing ease function that replicates the classic tween ease of the flash IDE
 * Can be used by TweenLite/TweenMax etc
 * Usage example:
 * TweenLite.to(mc, 2, {x:100, ease:ClassicEase.ease, easeParams:[50]});
 * @version 1.0
 * @author Reinier Feijen
 */
public class ClassicEase
{
	/**
	 * Ease function that replicates the classic tween ease of the flash IDE
	 * Can be used by TweenLite/TweenMax etc
	 * @param	t elapsed time of tween
	 * @param	b duration of tween
	 * @param	c min output value, at t=0
	 * @param	d total offset (max output value minus b, at t=d)
	 * @param	v classic ease value in range [-100,100] where a value < 0 is easeIn and value > 0 is easeOut. Larger values are also valid!
	 * @return output value in range [b..(b+c)]
	 */
	static public function ease(t:Number, b:Number, c:Number, d:Number, v:Number=0):Number 
	{
		if (v >= 0) return b + c * (1 - Math.pow((1 - t/d), 1 + Math.abs(v / 100) ));
		return b + c * (Math.pow(t/d, 1 + Math.abs(v / 100) ));
	}
}
}

 

Best,

 

Reinier

Link to comment
Share on other sites

Hi reinierf,

 

I never would have thought of that being a feature request, but if one person wants it, I'm sure there are others.

 

Its very nice of you to share your solution. I'm impressed.

 

 

Carl

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...