User Guide
194 ComboBox component
Example
With a ComboBox component instance my_cb, and a TextInput component instance
label_ti on the Stage, the following ActionScript code adds the user input to the combo box
when the user presses the Enter key:
// Add Items to List.
my_cb.addItem({data:1, label:"First Item"});
my_cb.addItem({data:2, label:"Second Item"});
// Create listener for user pressing Enter key on the Text Input field.
var tiListener:Object = new Object();
tiListener.enter = function(evt_obj:Object) {
my_cb.replaceItemAt(my_cb.selectedIndex, {label:evt_obj.target.text});
// Needed to refresh recently modified ComboBox entry
my_cb.selectedIndex = my_cb.selectedIndex;
};
label_ti.addEventListener("enter", tiListener);
See also
ComboBox.removeAll(), ComboBox.removeItemAt()
ComboBox.restrict
Availability
Flash Player 6 (6.0.79.0).
Edition
Flash MX 2004.
Usage
comboBoxInstance.restrict
Description
Property; indicates the set of characters that a user can enter in the text field of a combo box.
The default value is
undefined. If this property is null or an empty string (""), a user can
enter any character. If this property is a string of characters, the user can enter only characters
in the string; the string is scanned from left to right. You can specify a range by using a
dash (
-).
If the string begins with a caret (^), all characters that follow the caret are considered
unacceptable characters. If the string does not begin with a caret, the characters in the string
are considered acceptable.