So I'm trying to do something incredibly simple and It just isn't working properly. I'm annoyed at myself for not being able to find a solution but I need a fresh head on it!
Imagine we have a MovieClip called "box". When I click somewhere on the screen, I want the box MC to move to that position. So I wrote something like this (just for horizontal movement):
Now this works to a degree, except that when the box MC moves to the right position, it then proceeds to vibrate on the spot. I thought it was probably because it can never move to the exact position of _xmouse because I'm adding 10 to the x property which is why the condition is never met. However even if I just add 1 instead of 10, I still have the same problem..PHP Code:onMouseDown=function(){
moveTo(_xmouse);
};
function moveTo(newx){
box.onEnterFrame=function(){
if(box._x<newx){
box._x+=5;
}else if(box._x>newx){
box._x-=5;
}else{
delete box.onEnterFrame;
}
};
}
Any ideas before I go mad?
