1 Reply Latest reply on Apr 10, 2007 4:02 PM by Newsgroup_User

    Variable comparison problem

    symmetricalMan Level 1
      Actionscript newbie.

      I have three variables that I call as follows:
      _global johnAlt = false;
      _global garyAlt = false;
      _global tonyAlt = false;

      I also have three buttons, each of which changes the value of each variable, like:
      on (release) {tonyAlt = true;}

      Later, I need to compare the three values, so I've written code like this:
      if ((johnAlt = true) && (garyAlt = true) && (tonyAlt = true))
      {gotoAndPlay(3);}

      else {stop();}

      It doesn't work.
      I've tried using all sorts of combinations of code, including using double ==.

      The only way I got it to work was this way:
      if ((johnAlt = garyAlt) && (garyAlt = tonyAlt) && (tonyAlt = johnAlt))

      ...which essentially is what I'm asking all along, because I'm testing to see when they're all 'true'. But, what if I was trying to compare specific values, like
      if ((car=red) && (gofaster=stripes) && (bigbutton=off))?

      I've checked the Flash help, and various forums, and from what I can see, my code is suppsoed to work.

      Any ideas?
        • 1. Re: Variable comparison problem
          Level 7
          Have a look at this http://www.smithmediafusion.com/blog/?p=235
          It has some logic that might help.


          --

          Dan Mode
          --> Adobe Community Expert
          *Flash Helps* http://www.smithmediafusion.com/blog/?cat=11
          *THE online Radio* http://www.tornadostream.com <--check this

          *Must Read* http://www.smithmediafusion.com/blog


          "symmetricalMan" <webforumsuser@macromedia.com> wrote in message
          news:evh4j4$ksi$1@forums.macromedia.com...
          > Actionscript newbie.
          >
          > I have three variables that I call as follows:
          > _global johnAlt = false;
          > _global garyAlt = false;
          > _global tonyAlt = false;
          >
          > I also have three buttons, each of which changes the value of each
          > variable,
          > like:
          > on (release) {tonyAlt = true;}
          >
          > Later, I need to compare the three values, so I've written code like this:
          > if ((johnAlt = true) && (garyAlt = true) && (tonyAlt = true))
          > {gotoAndPlay(3);}
          >
          > else {stop();}
          >
          > It doesn't work.
          > I've tried using all sorts of combinations of code, including using double
          > ==.
          >
          > The only way I got it to work was this way:
          > if ((johnAlt = garyAlt) && (garyAlt = tonyAlt) && (tonyAlt = johnAlt))
          >
          > ...which essentially is what I'm asking all along, because I'm testing to
          > see
          > when they're all 'true'. But, what if I was trying to compare specific
          > values,
          > like
          > if ((car=red) && (gofaster=stripes) && (bigbutton=off))?
          >
          > I've checked the Flash help, and various forums, and from what I can see,
          > my
          > code is suppsoed to work.
          >
          > Any ideas?
          >
          >