3 Replies Latest reply on Nov 19, 2009 6:23 AM by Ned Murphy

    customized checkbox problem when using loadVariablesNum function

    xxxheeroxxx Level 1

      I have several cutomized checkbox that it can be selected or deselect and I have a button to determine which of the checkboxes is selected, and throught this button I passed the variable to loadVariablesNum corresponding to which of the checkboxes is selected.

       

      ==================================================

      code in the button to determine which of the checkboxes is selected:

      ==================================================

       

      if (chk1.mark1._visible = true){
              //trace("31");
              loadVariablesNum("http://url?uid="+_root.uid+"&ans=31", 2);
          }
          if (chk2.mark2._visible = true){
              //trace("32");
              loadVariablesNum("http://url?uid="+_root.uid+"&ans=32", 2);
          }
          if (chk3.mark3._visible = true){
              //trace("33");
              loadVariablesNum("http://url?uid="+_root.uid+"&ans=33", 2);
          }
          if (chk4.mark4._visible = true){
              //trace("34");
              loadVariablesNum("http://url?uid="+_root.uid+"&ans=34", 2);
          }
          if (chk5.mark5._visible = true){
              //trace("35");
              loadVariablesNum("http://url?uid="+_root.uid+"&ans=35", 2);
          }

        • 1. Re: customized checkbox problem when using loadVariablesNum function
          Ned Murphy Adobe Community Professional & MVP

          I am assuming you are having a problem with it not working.  One problem with it is that when you do comparison conditionals, you use == to see if things are equal, not =

           

          Also, not an error but to make less processing work... you should use "else" so that once the program finds a match it doesn't test all the remaining conditions, which yours would currently do.

           

          if (chk1.mark1._visible == true){
                  //trace("31");
                  loadVariablesNum("http://url?uid="+_root.uid+"&ans=31", 2);
              } else if (chk2.mark2._visible == true){
                  //trace("32");
                  loadVariablesNum("http://url?uid="+_root.uid+"&ans=32", 2);
              } else if....

           

          Also, the error solution can be simplified in your case because you are using boolean (true/false) values.  When a conditional tests something it is simply looking to see if the value within it evaluates as true or false, so your conditionals don't even need the "== true"

           

          if (chk1.mark1._visible){
                  //trace("31");
                  loadVariablesNum("http://url?uid="+_root.uid+"&ans=31", 2);
              } else if (chk2.mark2._visible){
                  //trace("32");
                  loadVariablesNum("http://url?uid="+_root.uid+"&ans=32", 2);
              } else if....

           

          One last thing... it appears you have unnecessarily created different checkbox symbols where you could have used the same one for all of them.  I say this due to seeing how you have different mark#'s for each one.   You just need to assign the same one different instance names....

           

          if (chk1.mark._visible){
                  //trace("31");
                  loadVariablesNum("http://url?uid="+_root.uid+"&ans=31", 2);
              } else if (chk2.mark._visible){
                  //trace("32");

           

          That example helps point out the difference between symbols and instances.  The same symbol (like a radio button or your home-made checkboxes) can be reused multiple times using different instance names for each instance.  You can then assign unique values to properties of each instance

          • 2. Re: customized checkbox problem when using loadVariablesNum function
            xxxheeroxxx Level 1

            Thanks Sir NedWebs greatly appreciated,

             

            I'm just experimenting on the mark#'s which I thought that makes it pin point unique symbol.

            But I just realize a moment after I posted it here that it is not necessary because the mark symbol is under a movieclip.

             

            I'm just confuse of what is the best to use AS3.0 or AS2.0. It seems AS2.0 is much more friendly and AS3.0 is more on the code side.

            All the samples when I search in google about AS3.0 samples all even animations is coded and nothing on the timeline but 1 frame which all objects is created.

             

            Thanks God Bless,

            • 3. Re: customized checkbox problem when using loadVariablesNum function
              Ned Murphy Adobe Community Professional & MVP

              You can design using AS3 the same way you do AS2, using the timeline.  Some designers have this quirk about doing everything in code and one frame.  That's great for them, but unnecessary overall.  Too often Flash designs are so basic in their nature that going that route is more of a complication than a solution and can make it harder to revise things down the road when you have to trace thru piles of code to find out how you designed something, versus seeing it laid out along a timeline.