# Mx 2004 tween class functions

**URL:** <https://forum.kirupa.com/t/mx-2004-tween-class-functions/183950>\
**Category:** Uncategorized\
**Created:** [March 31, 2006, 1:40pm UTC](https://forum.kirupa.com/t/mx-2004-tween-class-functions/183950 "2006-03-31T13:40:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [March 31, 2006, 1:40pm UTC](https://forum.kirupa.com/t/mx-2004-tween-class-functions/183950/1 "2006-03-31T13:40:29Z")

</div>

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

```auto

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

```auto

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

---

<div class="post-metadata">

**Author:** ![serkios](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/serkios/32/608_2.png) [@serkios](https://forum.kirupa.com/u/serkios)\
**Post date:** [March 31, 2006, 2:36pm UTC](https://forum.kirupa.com/t/mx-2004-tween-class-functions/183950/2 "2006-03-31T14:36:12Z")

</div>

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.

```auto
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…

---

<div class="post-metadata">

**Author:** ![mprzybylski](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mprzybylski/32/613_2.png) [@mprzybylski](https://forum.kirupa.com/u/mprzybylski)\
**Post date:** [March 31, 2006, 6:57pm UTC](https://forum.kirupa.com/t/mx-2004-tween-class-functions/183950/3 "2006-03-31T18:57:31Z")

</div>

I use the TweenExtended class by square circle ([www.sqcircle.com/downloads](http://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:

```auto
// 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:

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

```

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 1, 2006, 9:32am UTC](https://forum.kirupa.com/t/mx-2004-tween-class-functions/183950/4 "2006-04-01T09:32:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![serkios](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/serkios/32/608_2.png) [@serkios](https://forum.kirupa.com/u/serkios)\
**Post date:** [April 1, 2006, 5:39pm UTC](https://forum.kirupa.com/t/mx-2004-tween-class-functions/183950/5 "2006-04-01T17:39:52Z")

</div>

Yes you can use that in MX 2004

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 3, 2006, 10:34am UTC](https://forum.kirupa.com/t/mx-2004-tween-class-functions/183950/6 "2006-04-03T10:34:47Z")

</div>

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