Multiple eases in an MC

I have an MC that uses actionscript movement with easing… My question is how do I get the MC to move again after the first _x and _y coordinates are reached?

Im using this code so far…

[AS]onClipEvent (load) {
_x = 0;
_y = 0;
speed = 5;
}

onClipEvent (enterFrame) {
endX =400;
endY =300;
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;

}[/AS]

I tried using an If statement but it didnt seem to work, can someone show me the easiest way of doing this?

Thanks

[AS]onClipEvent (load) {
_x = 0;
_y = 0;
endX =400;
endY =300;
speed = 5;
}

onClipEvent (enterFrame) {
var dx = endX-_x ;
var dy = endY-_y ;
_x += dx / speed;
_y += dy / speed;
if ( Math.abs (dx) + Math.abs (dy) < 1 ) {
endX = 200 ;
endY = 150 ;
}
}[/AS]You could also use an array if there are more than 2 positions.

pom :slight_smile:

sweet, thanks pom!

Just out of curiosity, how would the array be set up? Im trying to pick up extra knowledge wherever I can…

It would be better with dynamic event handlers but here it goes:[AS]onClipEvent (load) {
_x = 0;
_y = 0;
speed = 5;
myDestinations = [{x:400,y:300},{x:40,y:350},{x:120,y:90}];
index = 0 ;
}

onClipEvent (enterFrame) {
var endX = myDestinations[index].x ;
var endY = myDestinations[index].y
var dx = endX-_x ;
var dy = endY-_y ;
_x += dx / speed;
_y += dy / speed;
if ( Math.abs (dx) + Math.abs (dy) < 1 ) {
index ++ ;
index = index % myDestinations.length ;
// that way, when you reach the last item of the array, you
// go back to the first item
}
}[/AS]

You could also change the destination only in the last if (to save some CPU usage).

Good luck!

pom :crazy:

Thanks Pom!:slight_smile:

Pom, you mind answering one more question?

Is it possible to add easing to motion tweens of MCs? Or no?

… Im so clueless its almost embarisning.

hehe, thanks for putting up with me