Help stopping the action

hello, i ok i am new to AS and i am making so where when u click on a square movieclip which has button in it a circle movieclip will come towards the the square you just clicked.

here is the code thats inside the square.

on(press){
_root.star1.endx = this._x;
_root.star1.endy = this._y;

_root.star1.onEnterFrame = function(){
speed = 3;
x = this.endx - this._x;
y = this.endy - this._y;
yrate = y/x;
xrate= 1;
isBehind=false;
if (this.endx < this._x){
yrate=-yrate;
xrate=-xrate;
isBehind=true;
}
this._x += xratespeed;
this._y += yrate
speed;
}
}

but problem i am having is stopping the circle. when it comes to the center of the square it just keeps moving in the middle. vibrating basicly. I tried putting if but that didnt work. nothing works and i need help plz.