# Multiple eases in an MC

**URL:** <https://forum.kirupa.com/t/multiple-eases-in-an-mc/26015>\
**Category:** Uncategorized\
**Created:** [July 18, 2003, 3:54pm UTC](https://forum.kirupa.com/t/multiple-eases-in-an-mc/26015 "2003-07-18T15:54:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![posix](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@posix](https://forum.kirupa.com/u/posix)\
**Post date:** [July 18, 2003, 3:54pm UTC](https://forum.kirupa.com/t/multiple-eases-in-an-mc/26015/1 "2003-07-18T15:54:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 4:09pm UTC](https://forum.kirupa.com/t/multiple-eases-in-an-mc/26015/2 "2003-07-18T16:09:41Z")

</div>

[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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 4:22pm UTC](https://forum.kirupa.com/t/multiple-eases-in-an-mc/26015/3 "2003-07-18T16:22:37Z")

</div>

sweet, thanks pom!

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 4:27pm UTC](https://forum.kirupa.com/t/multiple-eases-in-an-mc/26015/4 "2003-07-18T16:27:52Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 4:29pm UTC](https://forum.kirupa.com/t/multiple-eases-in-an-mc/26015/5 "2003-07-18T16:29:34Z")

</div>

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

Good luck!

pom :crazy:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 4:33pm UTC](https://forum.kirupa.com/t/multiple-eases-in-an-mc/26015/6 "2003-07-18T16:33:51Z")

</div>

Thanks Pom!🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 4:55pm UTC](https://forum.kirupa.com/t/multiple-eases-in-an-mc/26015/7 "2003-07-18T16:55:22Z")

</div>

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
