7 Replies Latest reply on May 26, 2006 12:24 PM by TimSymons

    button visibility

    Techmaniac Level 1

      I thought this would be simple ... buuuuuut no.
      if (NOT(this.atm_view.selected) {
      atm._visible = false;
      } else {
      atm._visible = true;
      }
      This doesn't do squat. So I figured I couldn't do a blanket button symbol visibility change. So I tested with the instance name of one button 7e_hay._visible = false; the damn thing comes back with a syntax error message!!?!

      If all instances of a button aren't affected by a visiblity change, and I named instances are syntax error, WHAT DO I DO NOW!?
        • 1. button visibility
          Mad_Rhino
          hey try using a ! instead of the NOT, like this

          if (!this.atm_view.selected) {
          atm._visible = false;
          } else {
          atm._visible = true;
          }
          • 2. Re: button visibility
            Techmaniac Level 1
            Nope. Tried that one beofre posting. It doesn't do anything. I don't know if that's because it won't afffect all instances of the button or not, and named instances bring syntax error.
            • 3. Re: button visibility
              Mad_Rhino Level 1
              Hi, can you exmplain a little more of the situation, how many buttons are involved etc..

              Thanks
              • 4. Re: button visibility
                Techmaniac Level 1
                31 instances of the ATM button. Each instance named uniquely based on street location. (ex. 7e_34wash). When the user clicks on the checkbox titled atm_view, I want to hide all instance of the ATM button.
                • 5. button visibility
                  Mad_Rhino Level 1
                  hey there again, the simpliest way i can think of is by you entering all the names of the buttons into an array, and then adding a function which will hide/show the atms when the checkbox is clicked. I came up with this code:

                  //Enter all the instance names of the atms here
                  var atmArray:Array = new Array("atm1", "atm2", "atm3", "atm4");

                  var totAtms:Number = atmArray.length;

                  function atmDisplay(_selected) {
                  for (var a:Number = 0; a<totAtms; a++) {
                  this[atmArray[a]]._visible = _selected;
                  }
                  }

                  checkBoxListener = new Object();
                  checkBoxListener.click = function(evt) {
                  var _selected:Boolean = evt.target.selected;
                  atmDisplay(_selected);
                  };
                  atm_view.addEventListener("click", checkBoxListener);

                  atm_view is the name of your checkbox.

                  Note: all the atms must be on the same level for this to work

                  Hope this helps
                  • 6. Re: button visibility
                    Techmaniac Level 1
                    That works fine. I guess the answer then is:
                    No, you have to use each instance name rather than tell all instances by calling just the symbol in general.
                    • 7. button visibility
                      TimSymons Level 1
                      Another way would be to use another class as a group class for the checkbox buttons. Then you could place the code to turn them all off in the group manager and then just call the group manager instance for global changes to all the buttons.

                      I use this all the time in creating navigation schemes and testing components. I used the code from the Checkbox button components that come with Flash as a starting point and then added only what I needed.

                      This is basically the same solution but you wrap it in a class so that you can attach it to new buttons as you need them.


                      I could send you a simple example if you are interested.

                      Tim