1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
//*********************** Filtrage ********************//
//******************** Declaration *******************//
import mx.collections.*;
private var collectionArray:Array;
[Bindable]
private var listcourriersARs:ArrayCollection;
import mx.controls.Alert;
import mx.events.ItemClickEvent;
private function init():void
{
collectionArray = [ {first: 1, last: 'Matthews'},
{first: 2, last: 'Chappelle'},
{first: 3, last: 'Grant'},
{first: 44, last: 'Baggins'},
{first: 2, last: 'Tandy'},
{first: 5, last: 'Simpson'},
{first: 9, last: 'Hilton'}];
listcour = new ArrayCollection(collectionArray);
}
//************************************************************************************************************//
public function filter():void {
listcour.filterFunction = filterFirst;
listcour.refresh();
}
public function filterReset():void {
listcour.filterFunction = null;
listcour.refresh();
}
private function filterFirst(item:Object):Boolean{
var isMatch:Boolean = false
if(item.last.toLowerCase().search(searchField.text.toLowerCase()) != -1){
isMatch = true
}
return isMatch;
}
private function search():void
{
if(searchField.text !='')
{
filter()
}
else
{
filterReset()
}
}
private function eraseText(event:MouseEvent):void
{
searchField.text ='';
} |