0 Replies Latest reply on Feb 28, 2011 2:19 PM by isabelle loyer

    Placing icons and label inside a ToggleButtonBar

    isabelle loyer

      As It's explain on subject, I try to create a custom ToggleButtonBar with icon and label on top.

      To do that, I create the class you can read below

      ********************************************
      package
      import mx.controls.Button;
      import mx.controls.ToggleButtonBar;
      import mx.core.IFlexDisplayObject;

      public class IconToggleButtonBar extends ToggleButtonBar

      {
      [Inspectable (enumeration = "left,right,top,bottom", defaultValue="left")]

      public var labelPlacement:String="left";

      override protected function createNavItem(label:String, icon:Class=null):IFlexDisplayObject
      {
      var b:Button = Button (super.createNavItem(label,icon));
      b.labelPlacement= labelPlacement;
      return b;
      }
      }
      }

      ********************************************

      To use this class, I had done:
      <fx:Script >
      <![CDATA[
      [Embed (source= "icon/paramList/archive.png")]
      public var icon1:Class ;

      private var listeObject:Object={label:"Label1", icon : icon1};
      private var actesObject:Object={label:"Label2", icon : icon1};
      private var preimpObject:Object={label:"Label3", icon : icon1};
      private var amoamcObject:Object={label:"Label4", icon : icon1};
      private var agendaObject:Object={label:"Label5", icon : icon1};

      [bindable]
      public var buttons:Array = [listeObject, actesObject, preimpObject, amoamcObject, agendaObject];

      ]]>
      </fx:Script>

      <component:IconToggleButtonBar
      dataProvider="{buttons}"
      itemClick="changeBbHandler(event)"
      includeIn="tout"
      selectedIndex="-1"
      toggleOnClick="true"
      x="7" width="95%"     
      color="0xff0000"
      height="49"/>

      *****************************************

      In my case, icon is visible on IconToggleButtonBar but no label appear.

      Is anyone can explain to me why?

      Thanks for helping