1 Reply Latest reply on Jul 31, 2010 6:43 PM by Peter Witham

    Using an ArrayList as the dataProvider for a ComboBox (FB4)

    the_grifter

      I come from Flex Builder 3 and have run into what I'm sure is a real simple problem.  I don't know how to use an ArrayList as the dataProvider for a ComboBox.  Here's what I have in ActionScript:

       

      [Bindable]

      private var _cbxdp:ArrayList = new ArrayList ([

         {label: '1 year'},

         {label: '2 years'},

         {label: '3 years'} ]);

       

      And here's the combobox:

       

      <s:ComboBox id="cbxWarrantyLength" width="125" dataProvider="{_cbxdp}" />

       

      Compiles fine, etc.  But when it loads the only thing in the combo box options are:  [object Object] (three times, one for each option).  In Flex Builder 3 all I would do is set the dataProvider to be like {_cbxdp.label} but I'm not sure how to do it in FB4.  Any hints?

       

      -The Grifter

        • 1. Re: Using an ArrayList as the dataProvider for a ComboBox (FB4)
          Peter Witham

          The code worked for me, I've pasted the complete code below for reference that I put in an AIR application ( just for quick testing)

           

          <?xml version="1.0" encoding="utf-8"?>

               <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

                       xmlns:s="library://ns.adobe.com/flex/spark"

                       xmlns:mx="library://ns.adobe.com/flex/mx">

               <fx:Script>

                    <![CDATA[

                         import mx.collections.ArrayList;

           

           

                         [Bindable]

                         private var _cbxdp:ArrayList = new ArrayList ([

                              {label: '1 year'},

                              {label: '2 years'},

                              {label: '3 years'} ]);

                    ]]>

               </fx:Script>

               <s:ComboBox id="cbxWarrantyLength" width="125" dataProvider="{_cbxdp}" />

          </s:WindowedApplication>

           

          Regards,

          Peter Witham