Tween Class part 2 – moving MC’s

moving mc’s 

In the previous post I used tweening to fade (_alpha) movieclips. Now we will try to complicate the situation and use the same routine to move some MC’s . Source:


import mx.transitions.Tween; // first the import
MovieClip.prototype.easeclip = function(startx,starty,endx,endy,speed) //movieclip extended
{
  //tweens for both x and y
  var movex:Tween = new Tween(this,"_x",mx.transitions.easing.Regular.easeOut,startx,endx,speed,false);
  var movey:Tween = new Tween(this,"_y",mx.transitions.easing.Regular.easeOut,starty,endy,speed,false);
};
// example usage
overlayMC.onRelease = function()
{
 YourMC.easeclip(YourMC._x,YourMC._y,Math.round(_xmouse),Math.round(_ymouse),30);
};

Note the usage of Math.round(); – MC’s in Flash do not like being positioned on half-pixels (i.ex. x:28.2 y:25.4) – using round or floor is a good solution for this problem.

I’m using “.Regular.easeOut” for the tweens – please note that there are several other options (depends on the effect you want to achieve) – Elastic.easeOut, easeIn, easeInOut and several others including the None.easeNone for “non-eased” transitions.
You can download the .FLA source here
Have Fun,

Flaim

Leave a Reply