1 Reply Latest reply on Aug 17, 2007 10:39 AM by hale2jo

    ButtonBar will not display icons...

      Hi, everyone. I'm using CentOS 4.3 with apache
      Tomcat 5.5.23 and Flex 2.0. I create a ButtonBar in my main.mxml
      file with a dataProvider that is an array of java Objects. Each
      Object has an icon, a label, and a toolTip among other things. The
      Adobe LiveDocs for ButtonBar says, "You can also populate the
      dataProvider property with an Array of Objects; where each object can
      have up to three fields: label, icon, and tooltip." (See
      http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Live Docs_Book_Parts&file=controls_059_08.html)
      I have those fields. The label and toolTip work great, but no icon is
      displayed. For the icon I've tried...
      (1) in the java Object:
      @Embed(source='someSwfFile.swf', symbol='SomeButton')


      (2) in the main.mxml file:
      [Embed(source='someSwfFile.swf', symbol='SomeButton')]
      public var SomeButtonCls:Class;
      and then
      setting the icon in the java object to SomeButtonCls

      Nothing works. Any help would be greatly appreciated!
        • 1. Re: ButtonBar will not display icons...
          hale2jo Level 1
          I finally figured it out. I thought I'd post what I did in case anyone else comes across this problem.
          in the mxml file:
          [Embed(source='someSwfFile.swf', symbol='SomeButton')]
          public var SomeButtonCls:Class;
          [Embed(source='someSwfFile.swf', symbol='SomeButton2')]
          public var SomeButton2Cls:Class;

          public var someObjList:Object;

          public function setIcon(): void
          var childNum:int = menuSomeButtonBar.numChildren-1;
          switch (someObjList.getItemAt(childNum).icon)
          case "SomeButtonCls": Button(menuSomeButtonBar.getChildAt(childNum)).setStyle("icon", SomeButtonCls); break;
          default: Button(menuSomeButtonBar.getChildAt(childNum)).setStyle("icon", SomeButton2Cls);

          <mx:ButtonBar id="menuSomeButtonBar"
          top="0" left="0"
          direction="vertical" verticalGap="10"
          dataProvider="{someObjList}" childAdd="setIcon()"
          buttonHeight="20" buttonWidth="20"/>

          Then in my Java code I fill a variable called icon in someObjList with SomeButtonCls or SomeButton2Cls as needed.