PDA

View Full Version : tween?



manny2k
October 7th, 2007, 08:42 AM
Hi

I have 4 or so movieclips which I use as buttons and want to move them all from the same starting point (_x) to different ending points using mc_tween, I can do this no problem, but I was wonder if there is a way get the same result using a for loop to tidy up the code. I’m not much of a coder so any advice or help would be really welcome.

Example: all mc's move from 0

Mc1 to say 100, mc2 to 200 , mc3 to 300 and mc4 to 400 etc etc

Thanks Manny2k

Michael Chen
October 7th, 2007, 06:33 PM
Try this...



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

mc1.xFinal = 50;
mc1.yFinal = 50;
mc2.xFinal = 200;
mc2.yFinal = 150;
mc3.xFinal = 300;
mc3.yFinal = 10;

for(var a = 1; a < 5; a++) {
new Tween(this["mc" + a], "_x", Strong.easeIn, this["mc" + a]._x, this["mc" + a].xFinal, 2, true);
new Tween(this["mc" + a], "_y", Strong.easeIn, this["mc" + a]._y, this["mc" + a].yFinal, 2, true);
}