Wednesday, August 31, 2011

Listening to Spark ComboBox Prompt Change

The spark ComboBox has a great feature of the prompt being editable by default. So how does one listen to the change of the text in the prompt.

One way of doing this is to listen to the change event fired by the ComboBox

<s:ComboBox id="comboBox" change="changeHandler(event)" />

private function changeHandler(event:IndexChangeEvent)
       //do something

The other way is to listen to the textChange of the prompt text

private function init():void
       comboBox.textInput.addEventListener(TextOperationEvent.CHANGE, textChangeHandler);

private function textChangeHandler(event:TextOperationEvent):void
       //Do Something

There. Hope someone finds use for this.

No comments :