1 Reply Latest reply on Jan 14, 2010 10:34 PM by Hottwiggz

    Is it possible to have one button for non active and another for active?

    Hottwiggz

      I have a program that displays images and has a container for "favorites".  Currently the container is blank unless you add an image to it, then there is a "remove all" button to remove any "favorites".  what I'm trying to do is have the button say "Favorites" and be present but inactive until a "favorite" is added.  If a favoreite is added the button would switch to say "remove favorites" and be active.

       

      <mx:Button

       

      styleName="Button.removeButton"

      visible="

      {_favoritesController.favoriteItems.length > 0}"

      click="onClear()"

      cornerRadius="

      0"

      alpha="

      1"

      themeColor="

      #F4F7F9"

      label="

      Remove Favorites"/>

       

       

       

      Basically what I'm trying to do is this.

      If _favoritesController.favoriteItems.length >0 "display Favorites image.jpg and be inactive"

       

      If _favoritesController.favoriteItems.length <0 "display Remove Favorites image.jpg and be active"

       

       

      As always any help is deeply appreciated.

        • 1. Re: Is it possible to have one button for non active and another for active?
          archemedia Level 4

          When you set the visible property like you did, setting the label has no effect because you wouldn't see the button anyway.

           

          This will change the label according to the number of items in you arrayCollection (I assume favoriteItems is an arrayCollection)

           

          <mx:Button

               enabled="{_favoritesController.favoriteItems.length > 0}"

           

               label="{_favoritesController.favoriteItems.length > 0 ? 'Remove Favorites' : 'Favorites'}"/>

           

          d

          1 person found this helpful