# \[FMX\]Moving mc from xpos to xpos and back

**URL:** https://forum.kirupa.com/t/fmx-moving-mc-from-xpos-to-xpos-and-back/52961
**Category:** flash
**Created:** [May 29, 2004, 8:19am UTC](https://forum.kirupa.com/t/fmx-moving-mc-from-xpos-to-xpos-and-back/52961 "2004-05-29T08:19:39Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)
#### Post date: [May 29, 2004, 8:19am UTC](https://forum.kirupa.com/t/fmx-moving-mc-from-xpos-to-xpos-and-back/52961/1 "2004-05-29T08:19:39Z")

</div>

I have a mc on the stage. I want the mc to move from one x position to another x position and back to it’s previous x position again, after a button is pressed.

I have the following function:

```auto
function moveClip (clip, xPos, speed){
clip.onEnterFrame = function (){
eindX = xPos - this._x;
this._x += eindX / speed;
if (Math.abs(eindX) < 2){
this._x = xPos;
delete this.onEnterFrame;
}
 
};
}

```

Is this the right function to accomplish what I want and if yes, what should be the action for the button?

Thanks in advance,  
Donald
