5 Replies Latest reply on Jun 23, 2007 2:19 PM by kglad

    Password check on button

    John T B
      Hi as you can probably guess I am not a programmer and I am fairly new to Flash.

      I have got the following code working on a button. I have a text box where the user adds his password and a combo box for the user to select the area he wants to go to. The on release part works to my amazement.

      on (release) {

      if (myInput == "XXXX" && Selectme.getValue() == "222") {
      goToAndStop("welcome");
      }
      else if(myInput == "YYYY" && Selectme.getValue() == "333") {
      goToAndStop("part1");
      }
      else if (myInput == "ZZZZ" && Selectme.getValue() == "444") {
      goToAndStop("part2");
      }
      else if (myInput == "HHHH" && Selectme.getValue() == "555") {
      goToAndStop("part3");
      }
      else {
      goToAndStop("wrong");
      }
      }

      I need the enter button on the keyboard to also work along with the click of the button. When I upgraded to Flash CS3 it stopped working. Can anyone help?
      Both scripts are on the same button.

      on (keyPress "<Enter>")
      if (myInput == "XXXX" && Selectme.getValue() == "222") {
      goToAndStop("welcome");
      }
      else if(myInput == "YYYY" && Selectme.getValue() == "333") {
      goToAndStop("part1");
      }
      else if (myInput == "ZZZZ" && Selectme.getValue() == "444") {
      goToAndStop("part2");
      }
      else if (myInput == "HHHH" && Selectme.getValue() == "555") {
      goToAndStop("part3");
      }
      else {
      goToAndStop("wrong");
      }
        • 1. Re: Password check on button
          kglad Adobe Community Professional & MVP
          are you publishing for as3 or as2?
          • 2. Re: Password check on button
            John T B Level 1
            Originally it was AS2, but I have upgraded to Flash CS3 so it is AS3.
            • 3. Re: Password check on button
              kglad Adobe Community Professional & MVP
              whether you're using as3 or as2 depends upon your publication settings (file/publication settings/flash), not the version of flash you're using.

              if you're going to use as3, you have to start reading the help documents. as3 is significantly different from as2 so your code for as2 will almost certainly generate compiler errors and fail when published for as3.

              to start, no code can be attached to a button or movieclip. because of your coding style, you should probably stay with as2 unless you want to learn as3.

              if you stay with as2, you should disable keyboard shortcuts when you test your code in the flash test environment. and both your handlers should be combined, separated by a comma:

              • 4. Re: Password check on button
                John T B Level 1

                Hi kglad,

                I have added the code like this onto the button but no joy.

                on (keyPress "<Enter>", release){

                if (myInput == "XXXX" && Selectme.getValue() == "222") {
                goToAndStop("welcome");
                }
                else if(myInput == "YYYY" && Selectme.getValue() == "333") {
                goToAndStop("part1");
                }
                else if (myInput == "ZZZZ" && Selectme.getValue() == "444") {
                goToAndStop("part2");
                }
                else if (myInput == "HHHH" && Selectme.getValue() == "555") {
                goToAndStop("part3");
                }
                else {
                goToAndStop("wrong");
                }
                }
                • 5. Re: Password check on button
                  kglad Adobe Community Professional & MVP
                  did you test in your browser or the test environment. if it was the test environment, did you disable keyboard shortcuts?