7 Replies Latest reply on Jan 3, 2007 1:10 PM by _Albertx_

    Is this correct?

    pecktron2000
      This is to make an "active state" for my buttons


      invA_but._visible=false;
      invB_but._visible=false;
      invC_but._visible=false;
      invD_but._visible=false;
      invE_but._visible=false;
      invF_but._visible=false;




      a_but.onRelease=function(){
      invA_but._visible=true;
      invB_but._visible=false;
      invB_but._visible=false;
      invD_but._visible=false;
      invE_but._visible=false;
      invF_but._visible=false;
      }

      b_but.onRelease=function(){
      invA_but._visible=false;
      invB_but._visible=true;
      invC_but._visible=false;
      invD_but._visible=false;
      invE_but._visible=false;
      invF_but._visible=false;
      }

      c_but.onRelease=function(){
      invA_but._visible=false;
      invB_but._visible=false;
      invC_but._visible=true
      invD_but._visible=false;
      invE_but._visible=false;
      invF_but._visible=false;
      }

      d_but.onRelease=function(){
      invA_but._visible=false;
      invB_but._visible=false;
      invC_but._visible=false;
      invD_but._visible=true;
      invE_but._visible=false;
      invF_but._visible=false;
      }

      e_but.onRelease=function(){
      invA_but._visible=false;
      invB_but._visible=false;
      invC_but._visible=false;
      invD_but._visible=false;
      invE_but._visible=true;
      invF_but._visible=false;
      }

      f_but.onRelease=function(){
      invA_but._visible=false;
      invB_but._visible=false;
      invC_but._visible=false;
      invD_but._visible=false;
      invE_but._visible=false;
      invF_but._visible=true
      }
        • 1. Re: Is this correct?
          CrazyMerlin Level 1
          it looks fine but is very over done.

          what you can have is a single function to which you pass a single Letter (A, B, C etc)
          the function would turn the visibility of all the buttons to false, then turn the button name you passed in to true, using eval() to get the name of the button.

          function setState(btn)
          {
          invA_but._visible = false;
          invB_but._visible = false;
          invC_but._visible = false;
          invD_but._visible = false;
          invE_but._visible = false;
          invF_but._visible = false;

          eval('inv' + btn + '_but_visible').visible = true;
          return;
          }

          To call: setState('A');
          I haven't tested this but it should work.

          //erlin!
          • 2. Re: Is this correct?
            pecktron2000 Level 1
            Thank you for replying!
            can you elaborate on:

            To call: setState('A');

            Thanks in advance, I really appreciate the help
            I'm relatively new with a.s.

            -R
            • 3. Is this correct?
              LB Back Level 1
              What CrazyMerlin means:
              • 4. Re: Is this correct?
                pecktron2000 Level 1
                Thank you guys!
                • 5. Re: Is this correct?
                  pecktron2000 Level 1
                  Didn't work :(

                  This is the code I attached to frame 1

                  function setState(btn)
                  {
                  invA_but._visible = false;
                  invB_but._visible = false;
                  invC_but._visible = false;
                  invD_but._visible = false;
                  invE_but._visible = false;
                  invF_but._visible = false;

                  eval('inv' + btn + '_but_visible').visible = true;
                  return;
                  }

                  a_but.onRelease = function() {
                  setState('A');
                  };
                  b_but.onRelease = function() {
                  setState('B');
                  };
                  c_but.onRelease = function() {
                  setState('C');
                  };
                  d_but.onRelease = function() {
                  setState('D');
                  };
                  e_but.onRelease = function() {
                  setState('E');
                  };
                  f_but.onRelease = function() {
                  setState('F');
                  }


                  is that right?
                  • 6. Re: Is this correct?
                    LB Back Level 1
                    Try: eval('inv' + btn + '_but_visible')._visible = true;
                    _visible instead of visible

                    Another thing; eval is deprecated if you wanna do it all right you should use the array-method:
                    this['inv'+btn+'_but_visible']._visible = true;
                    • 7. Is this correct?
                      _Albertx_ Level 1
                      why don't you send the button reference???

                      it's easier...


                      And then you can add or remove buttons to the array as you want. You don't have to type more code.