3 Replies Latest reply on Aug 21, 2007 9:20 AM by dimival

    conditional button

    kilyas2007 Level 1
      What would be the best way to put a consitional button in a flex app. e,g., if I have a variable named showButton, the button should be shown only if:

      showButton="show"

      else it should not be displayed. Any ideas?
        • 1. Re: conditional button
          kcell Level 2
          Don't know if there is a easier solution, but I suggest to write a As3 class which inherit from button with a member "showButton". The set methods would set the dimensions of the button to 0 (hide) or to a saved width/height (show).

          best regards,
          kcell
          • 2. Re: conditional button
            fragerdaz Level 1
            If you explicit how the condition is met (through what component or action), we might be able to give you a more suitable solution.
            • 3. Re: conditional button
              dimival Level 1
              Can't you simply bind the visible property of a button to a boolean variable?

              [Bindable]
              public var showButton:Boolean = false;

              <mx:Button visible="{showButton}"/>

              So whenever you set the showButton property to true or false it will affect the visibility of the button. You could put this in a custom component that extends the Button class, as kcell mentioned above.