# Totally at a loss

**URL:** <https://forum.kirupa.com/t/totally-at-a-loss/276472>\
**Category:** Uncategorized\
**Created:** [November 28, 2008, 4:59am UTC](https://forum.kirupa.com/t/totally-at-a-loss/276472 "2008-11-28T04:59:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaxGhost](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@MaxGhost](https://forum.kirupa.com/u/MaxGhost)\
**Post date:** [November 28, 2008, 4:59am UTC](https://forum.kirupa.com/t/totally-at-a-loss/276472/1 "2008-11-28T04:59:01Z")

</div>

Been trying to figure out how I can make this little jetplane thingy I made not pass the sides of the screen…

This is my code on the jet.

```auto

onClipEvent(load){
    speed = 20;
    xb = 20;
    yb = 20;
}

onClipEvent(enterFrame){
    if(Key.isDown(Key.RIGHT)){
        xb += speed;
    }else if(Key.isDown(Key.LEFT)){
        xb -= speed;
    }
    if(Key.isDown(Key.DOWN)){
        yb += speed;
    }else if(Key.isDown(Key.UP)){
        yb -= speed;
    }
    this._x = _x + (xb - _x) / speed; 
    this._y = _y + (yb - _y) / speed;
}

```

Now I need to get my borders to stop the jet from moving. The borders are simple lines (line tool, 1px each) along the sides of the stage. Each are called (in instance name, they’re each movieclips) bordertop\_mc, borderbottom\_mc, borderleft\_mc, and borderright\_mc.

Now, I cant figure out a way that will make the ship stop in its tracks without it going haywire… I understand how hittest works, but I just dont know how to try and make the jet\_mc movieclip stop moving completely at collision with a border, and still be able to have it go back in another direction when I press the opposite (say its at borderleft\_mc, hit the right key and it’ll go right, without it staying stuck on the borderleft\_mc)

byeah… I don’t know. ☹
