# Move a MC with constant speed and change it to ease in

**URL:** <https://forum.kirupa.com/t/move-a-mc-with-constant-speed-and-change-it-to-ease-in/65049>\
**Category:** flash\
**Created:** [September 22, 2004, 3:32pm UTC](https://forum.kirupa.com/t/move-a-mc-with-constant-speed-and-change-it-to-ease-in/65049 "2004-09-22T15:32:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Bolero](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@Tony\_Bolero](https://forum.kirupa.com/u/Tony_Bolero)\
**Post date:** [September 22, 2004, 3:32pm UTC](https://forum.kirupa.com/t/move-a-mc-with-constant-speed-and-change-it-to-ease-in/65049/1 "2004-09-22T15:32:59Z")

</div>

Hi!

How do I do this?

I want to move a mc with constant speed until it reaches a certain x/y value then it slows down and stop. All in as of course.

---

<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:** [September 23, 2004, 4:55am UTC](https://forum.kirupa.com/t/move-a-mc-with-constant-speed-and-change-it-to-ease-in/65049/2 "2004-09-23T04:55:58Z")

</div>

set up a framed loop.

frame 1  
gotoX=10;  
gotoY=10;

frame 2

// nothing

frame 3  
// here check if x and y of movieclip are not equal to the gotoX and gotoY  
// then subtract/add 5 pixels conditionally.  
//then gotoAndPlay(2);

---

<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:** [September 23, 2004, 9:15pm UTC](https://forum.kirupa.com/t/move-a-mc-with-constant-speed-and-change-it-to-ease-in/65049/3 "2004-09-23T21:15:08Z")

</div>

> [@Tony Bolero](#):
>
> Hi!
> 
> How do I do this?
> 
> I want to move a mc with constant speed until it reaches a certain x/y value then it slows down and stop. All in as of course.

MovieClip.prototype.checkr = function(tx, ty, speed) {  
this.frams = 0;  
this.speed = speed;  
this.tx = tx;  
this.ty = ty;  
this.vx = (this.tx-this.\_x)/this.speed;  
this.vy = (this.ty-this.\_y)/this.speed;  
this.onEnterFrame = move;  
};  
function move() {  
trace(“2”);  
this.\_x += this.vx;  
this.\_y += this.vy;  
this.frams++;  
if (this.frams\>=this.speed) {  
this.vx \*= .95;  
this.vy \*= .95;  
if (this.vx\<.1 && this.vy\<.1) {  
delete this.onEnterFrame;  
}  
}  
}

//example of use, movieclip instance name mc  
mc.checkr(400, 200, 80);

---

<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:** [September 27, 2004, 1:05pm UTC](https://forum.kirupa.com/t/move-a-mc-with-constant-speed-and-change-it-to-ease-in/65049/4 "2004-09-27T13:05:11Z")

</div>

Works perfect!

Thank you so much!

Tony Bolero
