Keyboard movement help

Well I am using this AS trying to get a movie clip to start moving when you press an arrow key, or change direction when already moving, but it doesn’t seem to work for me.

Hee is the code:

  if (_root.ingame == true) {
  if (keyPress(Key.DOWN)) {
   _root.dir = 1;
  } else if (keyPress(Key.UP)) {
   _root.dir = 2;
  } else if (keyPress(Key.LEFT)) {
   _root.dir = 3;
  } else if (keyPress(Key.RIGHT)) {
   _root.dir = 4;
  }
  if (dir == 0  && _root.game_b.user._y>(_root.game_b._y)) {
   _root.game_b.user._y -= _root.unit;
  } else if (_root.dir == 1 && _root.game_b.user._x>(_root.game_b._x)) {
   _root.game_b.user._x -= _root.unit;
  } else if (_root.dir == 2 && _root.game_b.user._y<(_root.game_b._height)) {
   _root.game_b.user._y += _root.unit;
  } else if (_root.dir == 3 && _root.game_b.user._x<(_root.game_b._width)) {
   _root.game_b.user._x += _root.unit;
  }
 }

Where game_b is the game board that is holding the user piece, user.

Any help would be appreciated. and I am sorry if a topic like this has been started already, or this isn;t the right area to post.