4 Replies Latest reply on Feb 18, 2008 1:37 PM by tomservo6

    Input text fields

    tomservo6
      Here's a two parter usin AS2 in CS3-

      I have two input text boxes, one for a user name and one for a password. There is also a button with an instance name of "enter_btn. There are additional frames labeled "correct" and "wrong". Here is the AS on the first frame:

      stop();
      enter_btn.onPress = function() {
      if ((username == "John") && (password == "awesome")) {
      gotoAndStop("correct");
      }
      else {
      gotoAndStop("wrong");

      };

      }


      That works fine except when the input text boxes have "auto kern" checked in the PI. When that is checked, it sends it to the "wrong" frame every time. Why should the auto kern affect the collecting of the variables?


      Second question-

      In the Flash help, it recommends not to use the "var" field in the PI to create input text field variables that will be populated by the user. It says that should only be done for previous versions of Flash players (even though it still works that way). I'm assuming that it then means to give the text field an instance name and define the variable in a frame action like:

      var name:String;

      If that's the case, what is the AS to tell the input text to be "name" and then test for it?

      var name:String;
      name_txt.text = name;
      button_mc.onPress = function() {
      if (name == "John") {
      gotoAndStop(10);
      } else {
      gotoAndStop(20);
      }
      };


      The above does not work.
        • 1. Re: Input text fields
          kglad Adobe Community Professional & MVP
          1. auto kerning enables the html property of your textfield so your textfied's variable has a load of html tags in it with whatever was entered buried in the middle somewhere.

          to resolve, use the text property of your textfield instead of its associated variable.

          2. is pretty well answered by reading 1. but you should be using

          name = name_txt.text;

          or better yet, just use the text property without creating another variable.
          • 2. Re: Input text fields
            tomservo6 Level 1
            That makes sense but I'm still missing something.

            username = mytext_txt.text;

            button_mc.onPress = function() {
            if (username == "John") {
            gotoAndStop(10);
            } else {
            gotoAndStop(20);
            }
            };

            Still doesn't work. I have auto kern off and no variable entered into the PI for the text field. It still goes to frame 20 (wrong).
            • 3. Re: Input text fields
              kglad Adobe Community Professional & MVP
              that assignment of username needs to be made when your button is pressed. or, just omit the use of an intermediate variable like username and use the textfied's text property in your if-statement. you'll avoid some foolish errors.
              • 4. Re: Input text fields
                tomservo6 Level 1
                That's it. I was overthinking it. Thanks.