Totally at a loss

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.


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. :frowning: