# Force to Math.ceil of another var

**URL:** <https://forum.kirupa.com/t/force-to-math-ceil-of-another-var/332421>\
**Category:** Uncategorized\
**Created:** [June 3, 2014, 10:23am UTC](https://forum.kirupa.com/t/force-to-math-ceil-of-another-var/332421 "2014-06-03T10:23:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dasLuft](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@dasLuft](https://forum.kirupa.com/u/dasLuft)\
**Post date:** [June 3, 2014, 10:23am UTC](https://forum.kirupa.com/t/force-to-math-ceil-of-another-var/332421/1 "2014-06-03T10:23:05Z")

</div>

I have this code on top of a movie clip that I need to go to where I click:

```auto
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!
