Using the arrow keys to move a mc

I have a window in flash that will display a section of a map, the map being very large. Similar to a mask type effect, you only see the window area. The arrow keys work to move the map up,down,left and right. This works, but the area I cannot get to work is preventing the map from continue past its limit, for example if I press down on the arrow keys the map will carry on past the scale of the map, so effectively I would want it to stop at the map end for all movements.

Can this be done, well of course, so please help if you have an idea. This map is just a sample, when I come to developing the proper map this is the effect I am really after, can anyone help me?

cheers

Trev

PS the action script I am using is as follows, the map is inside a mc.


function moveMap() {
	if (Key.isDown(Key.LEFT)) {
		map_mc._x -= 10;
	}
	if (Key.isDown(Key.RIGHT)) {
		map_mc._x += 10;
	}
	if (Key.isDown(Key.UP)) {
		map_mc._y -= 10;
	}
	if (Key.isDown(Key.DOWN)) {
		map_mc._y += 10;
	}
	updateAfterEvent();
}
function enableMove() {
	if (!moveSet) {
		checkKey = setInterval(moveMap, 10);
		_global.moveSet = true;
	}
}
function disableMove() {
	if (moveSet) {
		_global.moveSet = false;
		clearInterval(checkKey);
	}
}
userKey = new Object();
userKey.onKeyDown = enableMove;
userKey.onKeyUp = disableMove;
Key.addListener(userKey);
_global.moveSet = false;