2 Replies Latest reply on Oct 30, 2009 10:41 AM by Flex harUI

    Issue updating UI in event

    DMCericola

      I have an application which has three buttons sitting on top of one another but only is ever visible at a time.  On the initial setup of the app, the UI is correct but once one of the button clicked events fire multiple buttons show up at once.  All of the buttons are dynamicslly created and stored in a array for access.

       

      Some code snippits:

       

      The buttons are created like this, and then added to a canvas:


          browseButton.label = "Browse";
          browseButton.id = trackNumber.toString();
          browseButton.width = 92;
          browseButton.height = 30;
          browseButton.setStyle("right", 0);
          browseButton.addEventListener(MouseEvent.CLICK, fileRef_browseHandler);

             
          removeButton.label = "Remove";
          removeButton.id = trackNumber.toString();
          removeButton.width = 92;
          removeButton.height = 30;
          removeButton.setStyle("right", 0);
          removeButton.addEventListener(MouseEvent.CLICK, removeButton_clickHandler);

         
          clearButton.label = "Clear";
          clearButton.id = trackNumber.toString();
          clearButton.width = 92;
          clearButton.height = 30;
          clearButton.setStyle("right", 0);
          clearButton.addEventListener(MouseEvent.CLICK, clearButton_clickHandler);

       

          canvasButtons.addChild(removeButton);
          canvasButtons.addChild(browseButton);
          canvasButtons.addChild(clearButton);
          canvasButtons.horizontalScrollPolicy = "off";

      Easy enough.  So where the problem happens is in removeButton_clickHandler.  It goes through, and hides all the buttons and makes the browse button active as well as toggles another image.  It toggles the visiblity doing:

       

        public function HideFileButton(currentButton:Button):void {
              currentButton.setVisible(false);       
        } // HideFileButton(Button)

       

        public function ShowFileButton(currentButton:Button):void {
              currentButton.setVisible(true);
        } // ShowFileButton(Button)

       

      I can see that the visible property is changing but the UI isn't hiding the buttons that are no longer visible.  I got around this originally by setting the alpha to 0, but it seems like I'm missing something simple.

       

      Can anyone shed some light on what I'm missing?