0 Replies Latest reply on Apr 23, 2008 2:18 PM by badaboom_55

# [F8] How to move a MovieClip with Ease In/Out tween using Actionscript

In Flash 8, I need to move a MovieClip from point A to point B when a user clicks a button.
I currently have a function which I pass three arguments: TargetX, TargetY, and the Duration (in frames). I have it working to move the clip linearly, however, I would really like to be able to ease in/out on the tween.
I'm really stuck on the math of it all and need someone to give me the formula.
Here's my function:

Code:
// Function which is called when user clicks button to move the mc
_global.fMoveTheMovieClip = function(iTargetX, iTargetY, iDuration){

// Calculate the distance to the Target position
iTotalDistance = iTargetX - MoveThisClip_mc._x;

// Mover function
MoveThisClip_mc.onEnterFrame = function(){

// If the movie clip has gotten close enough to the target
if((Map_mc._x > iTargetX && Map_mc._x < (iTargetX + 1)) || (Map_mc._x < iTargetX && Map_mc._x > (iTargetX - 1))){

// Snap the movie clip to the target x
MoveThisClip_mc._x = iTargetX

// And stop this function
delete this.onEnterFrame;

// Else, if the mc has NOT reached the target zone
}else{
// Move the clip
// This is where I would like a formula to ease out then in based on the duration
// Right now I have this to move the mc at a constant speed
MoveThisClip_mc._x += (iTotalDistance / iDuration);

}
}
}

Also, everything needs to be AS2 compatible.
AND, I can't use the "tween" or "transitions" classes.
So, please don't post anything with code similar to this:

Code:
import mx.transitions.Tween
import mx.transitions.easing.*;

If I need to add a "power" or "strength" argument to my function, that's fine.

Thanks!!!!