ComboBox has the property "labelField" --- In [email protected], "devworkit" <[EMAIL PROTECTED]> wrote: > > Hi, > > I would like to have the dataprovider of a combobox be an array of a > custom class. I want to encapsulate a bunch of values/functions into > a class called MyClass. > > I see you can have a simple Object array in mxml as the dataprovider > like this: > > <mx:dataProvider> > <mx:Array> > <mx:Object label="1234567890" /> > <mx:Object label="The quick brown fox" /> > <mx:Object label="Lorem ipsum" /> > </mx:Array> > </mx:dataProvider> > > > BUT...I want the dataprovider to be an array of MyClass.....and that > MyClass has a public 'label' property (just like the generic Object > array has above) and a bunch of other properties and methods specific > to MyClass. > > The basic definition of MyClass is something like this: > > MyClass { > var label:String = null; > var myField:String = null; > var previewImg:Class = null; > } > > At runtime, I create an Array called myArray and then new-up instances > of MyClass, add values to it and then push it onto the myArray. I > then set this myArray as the dataprovider for a combobox. I drop down > the combobox and it has the correct number of items, but the labels > are all [object MyClass] I would have expected it to have the > 'label' value from each of my MyClass instances in myArray, and when I > get the selectedItem from the combobox, I would have access to the > myClass instance where I could then get access to other myClass > attributes/functions. > > Is this the right approach to have a custom class as the 'data' object > of a combobox item? > > Any ideas? > > Thanks! > > A combobox has a 'label' and a 'data' value. I would like the data to > be a custom class that encapsulates a bunch of values. > > For example: >

