3 Replies Latest reply on Nov 11, 2010 9:44 PM by smilelilac

    regarding Input text fields

    smilelilac Level 1

      This is about fill in the blanks in flash 8 as2. In this i used input  text fields and three buttons.In first frame i used multiple input text  fields and a submit button. After filling all the blanks we click on  submit button then in the second frame we will show the result like if  the blank is correct it should change the color to green and if it is  wrong it should change to red.and in the frame i have check button when  we click on it will display all the answers. And when we click on  analyse button we have to display the answer which the user types and  the correct answers.

       

      And my problem is when we click on submit there is no difference in the blanks color all are in black only and i have assigned red to the wrong answer and green to the correct answer.

       

      and script on submit button is

       

      on (release) {
          gotoAndStop("Bl1");
          if ((_root.Bl.txt1 == "abc1") && (_root.Bl.txt2 == "abc2") && (_root.Bl.txt3 == "abc3") && (_root.Bl.txt4 == "abc4")) {
              _root.Bl.txt1.textColor = 0x006600;
              _root.Bl.txt2.textColor = 0x006600;
              _root.Bl.txt3.textColor = 0x006600;
              _root.Bl.txt4.textColor = 0x006600;
          } else {
              _root.Bl.txt1.textColor = 0xFF0000;
              _root.Bl.txt2.textColor = 0xFF0000;
              _root.Bl.txt3.textColor = 0xFF0000;
              _root.Bl.txt4.textColor = 0xFF0000;
          }
      }

       

      where "Bl" is the movie clip name and "txt1","txt2","txt3","txt4" are the var names for input text fields

       

       

      Please help........

        • 1. Re: regarding Input text fields
          Darshan Rane Level 3

          You are concatenating the conditions it will only work if all are true or  all are false

           

          on (release)
          {
              gotoAndStop("Bl1");
             
              if (_root.Bl.txt1 == "abc1")
                  _root.Bl.txt1.textColor = 0x006600;
              else
                  _root.Bl.txt1.textColor = 0xFF0000;
             
              if (_root.Bl.txt2 == "abc2")
                  _root.Bl.txt2.textColor = 0x006600;
              else
                  _root.Bl.txt2.textColor = 0xFF0000;
             
              if (_root.Bl.txt3 == "abc3")
                  _root.Bl.txt3.textColor = 0x006600;
              else
                  _root.Bl.txt3.textColor = 0xFF0000;
                 
              if (_root.Bl.txt4 == "abc4")
                  _root.Bl.txt4.textColor = 0x006600;
              else
                  _root.Bl.txt4.textColor = 0xFF0000;
          }

           


          You can also run a for loop for optimizing the code further.

           

          --

          www.darshanrane.com

          1 person found this helpful
          • 2. Re: regarding Input text fields
            smilelilac Level 1

            Hi Darshan

             

            Thanks for the reply but i tried, there is not change in the result there is no change in the color.

            • 3. Re: regarding Input text fields
              smilelilac Level 1

              Solution:

               

               

               

              if (_root.Bl.txt1 == "abc") {

                       _root.Bl.tt1.textColor = 0x006600;

                   } else {

                       _root.Bl.tt1.textColor = 0xFF0000;

                   }

               

               

               

              where Bl is the movie clip name ,txt1 is the var  name of the input text f, tt2 is the instance name for the input text,so  we are giving two id's instance name and var name it worked.