F > FListBox.setDataProvider |
![]() ![]() ![]() |
FListBox.setDataProvider
Availability
Flash Player 6.
Usage
myListBox
.setDataProvider(
dataProvider
)
Parameters
dataProvider
An array of text strings listing the items to add, an instance of the Array object specifying the items to add, or an instance of the DataProvider class.
Returns
Nothing.
Description
Method; registers an outside object (dataProvider
) as the data source for the list box component. If dataProvider
is an instance of the Array object, the object can specify label
, data
, or both, because object properties and the contents of the array can be copied to the list box as labels, data, or both. If dataProvider
is an instance of the DataProvider class, it must implement the DataProvider API defined in the DataProvider symbol in the FlashUIComponents/CoreAssets/ClassTree folder in the library. The DataProvider API is for advanced users and programmers only; all other users should use an array or an Array object.
Example
The following code specifies the Array object writerList as the data provider for listBox1
.
listBox1
.setDataProvider(writerList);
The following code creates the array writerList to display the labels of the items listed in listBox1
.
writerList = new Array(); writerList[0] = "Jody"; writerList[1] = "Mary"; writerList[2] = "Marcelle"; writerList[3] = "Dale"; writerList[4] = "Stephanie"; writerList[5] = "Barbara";
The following code creates the array itemList1
, which specifies both the label and the data for list items. This Array object could be used as an alternate data provider for listBox1
.
itemList1
= new Array(); for (i=0; i<10; i++) { // create a real item var myItem = new Object(); myItem.label = "Item" + i; myItem.data = 75; // put it in the arrayitemList1
[i] = myItem; }
The following code specifies editorList, an instance of the DataProvider class, as the data provider for listBox1.
listBox1.setDataProvider(editorList);
The following code creates a new instance of the DataProvider class and then adds the item labels using the DataProvider addItem
method.
Note: The addItem
method is just one method of the DataProvider class. Programmers interested in using the DataProvider class should refer to the DataProvider symbol in the FlashUIComponents/CoreAssets/ClassTree folder in the library before attempting to use the methods.
editorList = new DataProviderClass(); editorList.addItem("Anne"); editorList.addItem("Rosana"); editorList.addItem("Lisa"); editorList.addItem("Rebecca");
See also
FListBox.addItem
, FListBox.replaceItemAt
, FListBox.sortItemsBy
![]() ![]() ![]() |