![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
Flash Player 6.0.79.
Flash MX 2004.
comboBoxInstance
.dataProvider
Property; the data model for items viewed in a list. The value of this property can be an array or any object that implements the DataProvider interface. The default value is []. This is a property of the List component but can be accessed directly from an instance of the ComboBox component.
The List component, and other data-aware components, add methods to the Array object's prototype so that they conform to the DataProvider interface (see DataProvider.as for details). Therefore, any array that exists at the same time as a list automatically has all the methods (addItem()
, getItemAt()
, and so on) needed for it to be the model of a list, and can be used to broadcast model changes to multiple components.
If the array contains objects, the labelField
or labelFunction
properties are accessed to determine what parts of the item to display. The default value is "label"
, so if such a field exists, it is chosen for display; if not, a comma separated list of all fields is displayed.
Note: If the array contains strings at each index, and not objects, the list is not able to sort the items and maintain the selection state. Any sorting will lose the selection.
Any instance that implements the DataProvider interface is eligible as a data provider for a List. This includes Flash Remoting RecordSets, Firefly DataSets, and so on.
This example uses an array of strings to populate the drop-down list:
comboBox.dataProvider = ["Ground Shipping","2nd Day Air","Next Day Air"];
This example creates a data provider array and assigns it to the dataProvider property, as in the following:
myDP = new Array(); list.dataProvider = myDP; for (var i=0; i<accounts.length; i++) { // these changes to the DataProvider will be broadcast to the list myDP.addItem({ label: accounts[i].name, data: accounts[i].accountID }); }
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |