DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Actionscript Perpetual Easing

11.20.2007
| 2173 views |
  • submit to reddit
        
MovieClip.prototype.ease = function(prop, target, speed) {
	delta = this['_' + prop] - target;
	if (delta != 0) {
		this['_' + prop] = this['_' + prop] - (delta / speed);
		delta = this['_' + prop] - target;
		if (delta < .25 and delta > -.25) {
			this['_' + prop] = target;
			delta = 0;
		}
	}
};