# Movieclip moves on 2nd frame

**URL:** <https://forum.kirupa.com/t/movieclip-moves-on-2nd-frame/209703>\
**Category:** Uncategorized\
**Created:** [December 11, 2006, 7:30pm UTC](https://forum.kirupa.com/t/movieclip-moves-on-2nd-frame/209703 "2006-12-11T19:30:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mario\_hater](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@mario\_hater](https://forum.kirupa.com/u/mario_hater)\
**Post date:** [December 11, 2006, 7:30pm UTC](https://forum.kirupa.com/t/movieclip-moves-on-2nd-frame/209703/1 "2006-12-11T19:30:41Z")

</div>

i have this code

```auto
onClipEvent (enterFrame) {
    if (_currentframe == 1) {
        thisframe = 1;
    } else {
        thisframe = 0;
    }
    if (thisframe == 1) {
        if (hamflat == 0) {
            if (hamgas == 0) {
                xdis = _x-_root.cuthbert_mc._x;
                ydis = -1*(_y-_root.cuthbert_mc._y);
                mangle = Math.atan2(ydis, xdis);
                angle = mangle/Math.PI*180;
                _rotation = -1*angle-90;
                distance = Math.sqrt(xdis*xdis+ydis*ydis);
                if (distance<resistance && distance>tooclose) {
                    this.gotoAndStop(2);
                    if (hamspeed<maxspeed) {
                        hamspeed += 5;
                    }
                } else {
                    this.gotoAndStop(1);
                }
                hamspeed *= deccel;
                xhamspeed = hamspeed*Math.sin(_rotation*(Math.PI/180));
                yhamspeed = hamspeed*Math.cos(_rotation*(Math.PI/180));
                _x += xhamspeed;
                _y -= yhamspeed;
            }
        }
    }
    if(thisframe==1){
        _alpha=100
    } else {
        _alpha=10
    }
}

```

the code detects wether the player is too close, then chases them if they are. This is not the problem however. The movieclip the code is on is on all the frames, however i only need him on the 1st frame. The problem is that the code should only allow him to move on the first frame and when he’s not he cant move. Please please please can somebody point me in the right direction.:hugegrin:
