2 Replies Latest reply on Mar 1, 2011 4:48 AM by Ned Murphy

    stopping an 'if' function

    TheEzmonator

      Hi there,

       

      I am trying to stop an if function from happening if a dynamic text box equals '1'

       

      if (facttrigger==1){

      _root.fact._x = 0;

      _root.resumebutton._x = 300;

      }

       

      I now want it to say that if the dynamic text box equals 1 then the _x and _y do not change.

       

      Thanks to anyone who can help.

        • 1. Re: stopping an 'if' function
          narmathadevi Level 1

          You are checking wrong way. You can try like this

           

          if (facttrigger.text==1){

          _root.fact._x = 0;

          _root.resumebutton._x = 300;

          }

          • 2. Re: stopping an 'if' function
            Ned Murphy Adobe Community Professional & MVP

            That is an open ended question because you haven't identified what happens if it doesn't equal 1.  Assuming facttrigger is a variable and not the instance name of the textfield, then what you are asking for would be coded as...

             

            if (facttrigger==1){

                 // do nothing 

            }

             

            which you could just as easily accomplish with no code at all.

             

            What you probably really intend is something that would be more like...

             

            if (facttrigger==1){

                 // do nothing 

            } else {

                 // do something (?)

            }

             

            which could be shortened to be...

             

            if (facttrigger != 1){

                 // do something (?)

            }

             

            If facttrigger is the instance name, then the first response provided is correct in pointing out the need to use the text property of the textfield, but to be more correct, text is a String entity, so t would more crorrectly be... facttrigger.text != "1"    OR   Number(facttrigger.text) != 1

            1 person found this helpful