My alternative is to use the protected textInput directly. This approach allows the "maxChars" property to be set in the GUI builder or code, just as you would for a normal TextField. Note that zero is a valid value for maxChars and indicates unlimited characters. The override of .childrenCreated() is needed to avoid attempting to set maxChars before the TextInput object exists.
package my.controls
{
import mx.controls.ComboBox;
public class EditableComboBox extends ComboBox
{
public function EditableComboBox()
{
super();
}
private var _maxChars:int = 0;
override protected function childrenCreated():void
{
super.childrenCreated();
// Now set the maxChars property on the textInput field.
textInput.maxChars = _maxChars;
}
public function set maxChars(value:int):void
{
_maxChars = value;
if (textInput != null && value >= 0)
textInput.maxChars = value;
}
public function get maxChars():int
{
return textInput.maxChars;
}
}
}