# Help with moving mc to set position and deleting enterframe?

**URL:** <https://forum.kirupa.com/t/help-with-moving-mc-to-set-position-and-deleting-enterframe/332278>\
**Category:** Uncategorized\
**Created:** [April 2, 2014, 12:51pm UTC](https://forum.kirupa.com/t/help-with-moving-mc-to-set-position-and-deleting-enterframe/332278 "2014-04-02T12:51:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![elvisbat](https://avatars.discourse-cdn.com/v4/letter/e/22d042/32.png) [@elvisbat](https://forum.kirupa.com/u/elvisbat)\
**Post date:** [April 2, 2014, 12:51pm UTC](https://forum.kirupa.com/t/help-with-moving-mc-to-set-position-and-deleting-enterframe/332278/1 "2014-04-02T12:51:22Z")

</div>

Hi all,

I am having difficulty remembering how to move a movieclip to an x and y position by reducing or increasing it’s x and y until it has reached the location.

It is only working from one direction and not always deleting the onenterframe and sometimes stopping before it reaches the set position?

This is what i have so far!

```auto
    _root.Hull2.myFinalX = 590;
    _root.Hull2.myFinalY = 345;

    _root.Hull2.onEnterFrame=function(){

        if (mousePressed == false && _root.onTarget == false) {
        _root.Hull2._x = _root.Hull2._x 
        _root.Hull2._y = _root.Hull2._y 
            
        } else if (mousePressed == false && _root.onTarget == true) {
 
        if(_root.Hull2._x!=MynewX && _root.Hull2._y!=MynewY){
            
        MynewX = Math.round(this._x -= (this._x-this.myFinalX)/5);
        MynewY = Math.round(this._y -= (this._y-this.myFinalY)/5);
         trace("MynewX="+MynewX)
        trace("MynewY="+MynewY)
        }else{
        
        delete this.onEnterFrame;
        trace("deleted")
        
        }
}

```
