0 Replies Latest reply on Aug 30, 2006 12:17 PM by Matt-R

    Keyboard controls for a map

    Matt-R
      I am unsuccessfully trying to incorporate keyboard controls to a map which the user can pan up, down, left and right. Currently the user can pan using the mouse and some buttons I created. All the action script is contained in one frame and references the buttons by instance name (ie. the pan left button is called "pan_left")

      I want to be able to use the keyboard arrows to do the same thing. I am hoping I can just add some code to my existing code. Below is the code I am using for the panning. Does anyone have any ideas how I can easily add keyboard controls to the code below. I just need some help with making it work for one direction and I will adjust it for the others.

      pan_up.onPress = function() {
      onEnterFrame = function () {
      map._y += 50;
      updateButtons();
      };
      };
      pan_down.onPress = function() {
      onEnterFrame = function () {
      map._y -= 50;
      updateButtons();
      };
      };
      pan_left.onPress = function() {
      onEnterFrame = function () {
      map._x += 50;
      updateButtons();
      };
      };
      pan_right.onPress = function() {
      onEnterFrame = function () {
      map._x -= 50;
      updateButtons();
      };
      };
      this.onMouseUp = function() {
      this.onEnterFrame = null;
      };

      updateButtons = function () {
      zoom_in.enabled = true;
      zoom_out.enabled = true;
      pan_up.enabled = true;
      pan_down.enabled = true;
      pan_left.enabled = true;
      pan_right.enabled = true;
      if (map._xscale>maxZoom) {
      map._xscale = map._yscale=maxZoom;
      zoom_in.enabled = false;
      delete onEnterFrame;
      }
      if (map._xscale<minZoom) {
      map._xscale = map._yscale=minZoom;
      zoom_out.enabled = false;
      delete onEnterFrame;
      }

      };
      updateButtons();