User Guide

206 ComboBox component
Example
The following code restricts the text box of myComboBox so that it only accept numbers to
maximum of six characters:
// Add Items to List.
my_cb.addItem({data:0xFFFFFF, label:"white"});
my_cb.addItem({data:0x000000, label:"black"});
my_cb.editable = true;
// Restrict what can be entered into textfield to only 0-9.
my_cb.restrict = "0-9";
// Limit input to 6 characters.
my_cb.textField.maxChars = 6;
ComboBox.value
Availability
Flash Player 6 (6.0.79.0).
Edition
Flash MX 2004.
Usage
comboBoxInstance.value
Description
Read-only property; if the combo box is editable, value returns the item label. If the combo
box is static,
value returns the item data.
Example
The following example puts the data into the combo box by setting the dataProvider
property. It then displays the
value in the Output panel. Finally, it selects "California" and
displays it in the Output panel while the combo box is editable, and then displays
"CA" when
the combo box is not editable.
my_cb.dataProvider = [
{label:"Alaska", data:"AK"},
{label:"California", data:"CA"},
{label:"Washington", data:"WA"}];
my_cb.editable = true;
my_cb.selectedIndex = 1;
trace('Editable value is "California": ' + my_cb.value);
my_cb.editable = false;
my_cb.selectedIndex = 1;
trace('Non-editable value is "CA": ' + my_cb.value);