I have this code on top of a movie clip that I need to go to where I click:
onClipEvent (load) {
speed = 3;
}
onClipEvent (mouseDown) {
// flip mc right or left
if (_root._xmouse < this._x)
{
setProperty(this, _xscale, -100);
}
else if (_root._xmouse > this._x)
{
setProperty(this, _xscale, +100);
}
// make mouse coordinates integers
endX = Math.ceil(_root._xmouse);
endY = Math.ceil(_root._ymouse);
// check mc's _x _y and move to mouse
if (_x != endX && _y != endY)
{
this.onEnterFrame = function():Void
{
this._x += (this.endX - this._x) / this.speed;
this._y += (this.endY - this._y) / this.speed;
// i tried to round them up like this but it doesnt always equal the destination
this._x = Math.ceil(this._x);
this._y = Math.ceil(this._y);
// if the clip reached destination kill the onEnterFrame << this is what i want to happen all the time to save CPU
if (_x == endX && _y == endY)
{
delete this.onEnterFrame;
trace("kill");
trace("x mc " + _x);
trace("x click " + endX);
trace("y mc " + _y);
trace("y click " + endY);
trace("XXXXXXXXXXXX");
}
trace("x mc " + _x);
trace("x click " + endX);
trace("y mc " + _y);
trace("y click " + endY);
trace("_____________");
};
}
}
How can I force the _x and _y of my clip to always = the endX and endY ?
I run this at 30fps.
Thanks!