Filter TextInput
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Canvas>
<mx:Script>
[Bindable]
private var probableMatches:Array;
private var allWords:Array = ["apple", "boy", "cat"];
private var regexp:RegExp;
private function checkInput():void
{
var temp:Array = allWords.filter(filter);
if(temp){
input.text = temp[0];
}
}
private function filter(element:*, index:int, arr:Array):Boolean
{
regexp = new RegExp(input.text);
return (regexp.test(element as String));
}
</mx:Script>
<mx:TextInput id="input" change="checkInput()"/>
</mx:Canvas>
</mx:Application>
Related examples in the same category