• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

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

New Here ,
Jul 31, 2010 Jul 31, 2010

Copy link to clipboard

Copied

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

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 31, 2010 Jul 31, 2010

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines