5 Replies Latest reply on Apr 28, 2006 5:14 PM by bxSiN

    How do  I define a boolean?

    bxSiN
      I feel stupid about asking this, but I've never really had a need to use much actionscript....

      regardless, I'm needing do have a bool that will get check by buttons, so how do I declare/define it? I work in game code, all I do is bool blablabla; and thats it. I've been looking at dictionary in flash, but it isn't much helps.

      is it: Boolean( myBool ); or what?

      and do I check a boolean the same as I would in c++, e.g. myBool == 1?

      Thanks.

        • 1. Re: How do  I define a boolean?
          kglad Adobe Community Professional & MVP
          you can use the following:
          • 2. Re: How do  I define a boolean?
            Level 7
            var bVar:Boolean = true; // or false
            ...

            if (bVar) {
            // what to do if it's true
            } else {
            // what to do if it's false
            }


            if you want to test if its values is false: if (!bVar)



            bxSiN wrote:
            > I feel stupid about asking this, but I've never really had a need to use much
            > actionscript....
            >
            > regardless, I'm needing do have a bool that will get check by buttons, so how
            > do I declare/define it? I work in game code, all I do is bool blablabla; and
            > thats it. I've been looking at dictionary in flash, but it isn't much helps.
            >
            > is it: Boolean( myBool ); or what?
            >
            > and do I check a boolean the same as I would in c++, e.g. myBool == 1?
            >
            > Thanks.
            • 3. Re: How do  I define a boolean?
              bxSiN Level 1
              thanks.

              so I could put that in say the first frame on the main timeline and be able to query to bool from a button or inside a movie clip?
              • 4. Re: How do  I define a boolean?
                kglad Adobe Community Professional & MVP
                yes but, as always, you'll need to use the correct path to your variable.
                • 5. Re: How do  I define a boolean?
                  bxSiN Level 1
                  ok, more questions in relation to bools.

                  This is what I have.

                  Main timeline in frame1, created my bools and set them all to false. I have 4 buttons on the main timeline as well. If each button I have code that needs to check if the bools are true, do something else, and then set the one of the bools to true so the other buttons will know they're used. Here is the code, it might make sense:

                  quote:

                  on(press){
                  if( nav2Loaded ){
                  _root.navmc2.gotoAndPlay( [unload], 1 );
                  }
                  if( nav3Loaded ){
                  _root.navmc3.gotoAndPlay( [unload], 1 );
                  }
                  if( _root.nav4Loaded ){
                  _root.navmc4.gotoAndPlay( [unload], 1 );
                  }
                  }
                  on(release){
                  if( !nav1Loaded ){
                  loadMovie( "nav1.swf", navmc1 );
                  }
                  _root.nav1Loaded = true;
                  }


                  is this right? or do I have to specify the frame the original bool is in?