0 Replies Latest reply on May 18, 2006 11:40 AM by dmcdonald

    Code check

    dmcdonald Level 1
      I am trying to track a users interaction - they basically need to type in "la" and hit the tab button. If they type in la and hit enter I want to give them a message telling them to use the tab key. They get an error message if they type in something different or use the control or enter key. They get a message letting them know they are correct if they type in la and use the enter or control key. Can anyone spot something wrong with my code? It seems to work hit and miss...


      choicez = "";
      Selection.setFocus("choicez");
      choicez.tabEnabled;
      choicez.tabIndex = 1;
      UserKey = new Object();
      UserKey.onKeyDown = function() {
      if ((key.getCode() == Key.TAB) && (choicez == "la")) {
      Key.removeListener(UserKey);
      gotoAndPlay("layes");
      } else {
      if ((key.getCode() == Key.TAB) && !(choicez == "la")) {
      Key.removeListener(UserKey);
      gotoAndPlay("lano");
      }
      if (((key.getCode() == Key.CONTROL) || (key.getCode() == Key.ENTER)) && !(choicez == "la")) {
      Key.removeListener(UserKey);
      gotoAndPlay("lant");
      }
      if ((key.getCode() == Key.TAB) && (choicez == "la")) {
      Key.removeListener(UserKey);
      gotoAndPlay("lant");
      }
      }
      };
      Key.addListener(UserKey);
      stop();