3 Replies Latest reply on May 31, 2008 6:19 PM by Ned Murphy

    Button alpha change on text event

    Ponchotg
      Hi:
      im a newbie so bare with me a little please.
      im not that new to Flash but i am used to make simple videos or games even web pages but this time i've got a harder task on my hands

      im on flash CS3 using AS2
      im working on a project that at the end has a little test
      that text is sent to the manager of the person doing it... i had no trouble with that.
      but in order to be able to go to the next screen the user MUST enter at least some text on the input text... the easiest way i thought of was to change the "next" button alpha to "0" and change it to 100 when the user writes something...

      but i have no idea how to do this... i saw there are commands like onChange etc. but i have no idea how to use them

      basicaly i need to change the buttons alpha from "0" to "100" when a user writes something on the text field called "TEXT1" the button is called "Nextbut"
      Thanks in advance for your help i really appreciate it!
        • 1. Re: Button alpha change on text event
          Noelbaland Level 1
          Hello,

          There's no need to change the alpha of a button.

          You would start by disabling your button and then detect if the textfield has changed. If it has then allow your button to be enabled.

          Lets assume an Input textfield (instance named "input_txt") and a button (instance named "submit_btn") have been created on the stage.

          The following code would go in a frame on a layer called "actions".

          [Actionscript 2]

          // Disable the button first
          submit_btn.enabled = false;

          // Check if the user types something in the text field and then
          input_txt.onChanged = function()
          {
          // Enable the button
          submit_btn.enabled = true;
          }

          Thats it! Try it and see if it works.
          • 2. Re: Button alpha change on text event
            Ponchotg Level 1
            Excelent worked like a charm... thank you very much!
            • 3. Re: Button alpha change on text event
              Ned Murphy Adobe Community Professional & MVP
              If the user must have something entered before they can proceed, then you should test the string length in the changed function (in the event they enter something and then remove it). Also, another option to using enabled which parallels your desire to change the alpha would be to set the _visible property false/true...

              // Hide the button first
              submit_btn._visible = false;

              // Check if the user types something in the text field and then
              input_txt.onChanged = function()
              {
              if(input_txt..text.length > 0){ // Show the button
              submit_btn._visible = true;
              } else { // Hide the button
              submit_btn._visible = false;
              }
              }