simple search Component
use ::
<component:searchComp dataProvider=”{ArrayCollection}” filterProperty=”type” width=”200″ />
This is how we can create a dyanmic filter funtion to work on different properties of object
private function filterFunc(item:Object):Boolean
{
if(String(item[filterProperty]).indexOf(searchTxt) >= 0)
return true;
else
return false;
}
Component Code ::
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Canvas xmlns:mx=”http://www.adobe.com/2006/mxml” creationComplete=”onInit()”>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
private var searchTxt:String;
public var filterProperty:String = "label";
[Bindable]
public var dataProvider:ArrayCollection;
private function onInit():void
{
dataProvider.filterFunction = filterFunc;
}
private function filterFunc(item:Object):Boolean
{
if(String(item[filterProperty]).indexOf(searchTxt) >= 0)
return true;
else
return false;
}
private function onTextChangeHandler(event:Event):void
{
searchTxt = event.target.text;
dataProvider.refresh();
}
]]>
</mx:Script>
<mx:Label id=”serch_lb” text=”Search” left=”2″ top=”4″/>
<mx:TextInput id=”serch_txt” text=”" right=”2″ top=”4″ left=”50″ change=”onTextChangeHandler(event)”/>
</mx:Canvas>
see here :: http://jasmeetsehgal.googlepages.com/searchCompSample.html
Download the source and rename it to rar and unzip for using it

