Setting Boundaries

Ok, I have a scrolling terrain and I put the scrolling code on the player. Heres the code:

onClipEvent (load) {

movespeed = 5;

}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
    _root.terrain._x -= movespeed
play();
_rotation = 90;
_x += movespeed;
}
if (Key.isDown(Key.LEFT)) {
    _root.terrain._x += movespeed
play();
_rotation = 270;
_x -= movespeed;
}
if (Key.isDown(Key.UP)) {
    
_root.terrain._y += movespeed
play();
_rotation = 0;
_y -= movespeed;
}
if (Key.isDown(Key.DOWN)) {
_root.terrain._y -= movespeed
play();
_rotation = 180;
_y += movespeed;
}
if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP)) {
_rotation = 45;
}
if (Key.isDown(Key.LEFT) && Key.isDown(Key.UP)) {
_rotation = 315;
}
if (Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN)) {
_rotation = 135;
}
if (Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN)) {
_rotation = 225;
}
}

I know its messy, but I’m a noob in AS and I don’t know how to make it any cleaner. Anyway, it works fine except now I want to set a limit to how far it can scroll before it stops. Heres the part I’m stumped on; I don’t know how to make it stop! Yes, it may be obvious to you guys, but I’m just started doing this AS thing, and still relativaly new to this stuff. Any help would be appreciate.

I’ve created a new file, just for the scrolling. I think I made the code a little cleaner:

attachMovie("terrain_mc", "terrain_mc1", this.getNextHighestDepth());

_root.terrain._mc1._x = 0;


onEnterFrame = function () {
    if (Key.isDown(Key.RIGHT)) {
        trace("Key RIGHT is Down");
        if (_root.terrain_mc1._x>-400) {
            _root.terrain_mc1._x -= 10;
        } else {
            if (Key.isDown(Key.LEFT)) {
                trace("Key LEFT is Down");
                if (_root.terrain_mc1._x>0) {
                    _root.terrain_mc1._x += 10;
                }
            }
        }
    }
}

I don’t know why, but only the first “if” statement gets processed. It works only for the first one but I need help figuring out why it only reads one and not two.