[FMX]Moving mc from xpos to xpos and back

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:

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