Tuesday, May 05, 2009

Flex Auto Complete / Predictive Text Example

Ok this basically works with a change event placed on a textInput or other component you can modify it to your needs

<-- First the action script -->
<--
Now create a variable that will be your dictionary this can come from a query or whatever
-->
private var xDictionary:Array = ["Alan","Brad","Cindy","Dana","Elizabeth","Frank"];
private var regexp:RegExp;

private function xTestInput():void{
var i:int = 0;
var temp:Array = xDictionary.filter(filter);
txInput.text = temp[0];
}

private function filter(element:*,index:int,arr:Array):Boolean{
regexp = new RegExp(txInput.text);
return (regexp.test(element as String));
}

<--
And in your MXML
-->

0 comments:

Wiredwizrd

in memphis, tn morgan todd Located in Raleigh, NC Morgan Todd has over 15+ years experience, as a Sr. IT Analyst and Freelance Developer Working in lead positions with various high energy companies, and Marketing Firms Securing and Developing enterprise level applications A Professional Penetration Tester, performing code review and pen testing for PCI_DSS, HEPA, and SOXS compliance, functionality, and best practices. for various corporate clients.