Mx 2004 tween class functions

I use this function often. It is nothing new, and no im not a purist. Im hoping that having this information here, may help someone else in some way.

easing methods;

Strong
Back
Elastic
Regular
Bounce
None

easing types;

easeIn
easeOut
easeInOut
easeNone

make something tween


overTween = mx.transitions.easing.Strong.easeOut;
//(instance, property, tweentype, start val, end val , time )
tweenIt(myInstance.hl, "_alpha", overTween, 0, 100, 2);

the function that makes stuff tween


function tweenIt(Ttarget, Tprop, TeaseType, Tbegin, Tend, Ttimet) {
    target=Ttarget, prop=Tprop, easeType=TeaseType, begin=Tbegin, end=Tend, timet=Ttimet;
    myTween = new mx.transitions.Tween(target, prop, easeType, begin, end, timet, true);
}

let me know of anyway I could improve this :moustache

Here’s an example of some code I frequently use. A few less things to pass and creates tweens for both _x and _y for you.

MovieClip.prototype.easeInOut = function(endX, endY, secs) {
	var easeType = Regular.easeInOut;
	var startX = this._x;
	var startY = this._y;	
	
	if (this.xTween == undefined) {
		this.xTween = new Tween(this, "_x", easeType, startX, endX, secs, true);
		this.yTween = new Tween(this, "_y", easeType, startY, endY, secs, true);
	} else {
		this.xTween.continueTo(endX, secs);
		this.yTween.continueTo(endY, secs);
	}
};

Maybe you’ll find it useful…

I use the TweenExtended class by square circle (www.sqcircle.com/downloads). it allows you to tween multiple properties in one line using arrays. here is som code i normally use which allows me to also have a callback function and pass parameters to it:

// set a function to handle tweening
function tweener(mc:MovieClip, props:Array, easeFunc:Function, startVals:Array, endVals:Array, dur:Number, useSecs:Boolean, cb:Function, ob:Object, params:Array):Void
{
    var _tween:TweenExtended = new TweenExtended(mc, props, easeFunc, startVals, endVals, dur, useSecs);
    
    _tween.onMotionFinished = function():Void 
    {
        cb.apply(ob, params);
    };
}

usage:

tweener(ticker, ["_x", "_y"], Regular.easeOut, [465, 50], [-1765, 20], 30, true, showNext, this, [5, 4]);

sorry for my ignorance mprzybylski. I haven’t used import yet.
can i use that with mx 2004?

Yes you can use that in MX 2004

ahhh… think i will be using yours… :drool: