1 Reply Latest reply on Feb 11, 2007 2:58 AM by Cheree Singal

    combobox and images

    karina_a
      DEar everyone,

      Since I am new in Flex... I was wondering if it is possible to display a list of countries with a small flag image in a combobox like:
      [flag image] Australia
      [flag image] Argentina
      [flag image] Bolivia
      ....

      If it is possible... could you please provide me with an example?,

      Tx so much in advance,

      Karina
        • 1. Re: combobox and images
          Cheree Singal Level 1
          Hi Karina,
          I have been able to show images in a drop-down list of combo-box using following code:

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical"
          creationComplete="initApp()">
          <mx:Script>
          <![CDATA[
          import mx.collections.ArrayCollection;
          public var ac: ArrayCollection = new ArrayCollection();
          public function initApp(): void{
          //Add images in this way.
          ac.addItem({source: " image path", label: " Country name"});
          }
          ]]>
          </mx:Script>
          <mx:ComboBox id="imageCombo" dataProvider="{ac}">
          <mx:itemRenderer>
          <mx:Component>
          <mx:HBox>
          <mx:Label text="{data.label}"/>
          <mx:Image source="{data.source}"/>
          </mx:HBox>
          </mx:Component>
          </mx:itemRenderer>
          </mx:ComboBox>
          </mx:Application>

          But when an item is selected, the image is not shown.
          i am trying to make it work. For the mean time, hope this helps u...

          Cheree