F > FListBox.addItem

 

FListBox.addItem

Availability

Flash Player 6.

Usage

myListBox.addItem(label [, data])

Parameters

label A text string specifying the item to add to the list.

data A value associated with the list item. This parameter is optional.

Returns

Nothing.

Description

Method; adds a new item with the specified label and data (optional) to the end of the list box, updates the list box, and resizes the scroll bar. The Data parameter can be any Flash object, string, Boolean value, integer, object, or movie clip.

For best performance and load-time results, you should not add more than 400 items in a single frame. This applies whether you are adding the items to a single list box or to several list boxes.

Example

The following code adds Lyvia to the list of items displayed in the list box coolGirls.

coolGirls.addItem("Lyvia");

The following code adds the maximum number of items recommended in a single frame (400 items) to listBox1:

for (i=0; i<400; i++) {
   listBox1.addItem(i); 
}

The following code adds the maximum number of items recommended in a single frame (400 items) to listBox1 and comboBox2:

for (i=0; i<200; i++) {
   listBox1.addItem(i);
   comboBox2.addItem(i);
}

See also

FListBox.addItemAt, FListBox.getItemAt, FListBox.removeItemAt, FListBox.replaceItemAt, FListBox.sortItemsBy