**UPDATE**
Thanks to the help of Nolan I was able to get it to:
- works with case-sensitivity
- and resets data as you type.
-------------------------------------
I redid the ArrayCollection example so take a look at this example:
Actionscript:
-
<?xml version="1.0" encoding="utf-8"?>
-
-
<![CDATA[
-
import mx.collections.*;
-
-
private var collectionArray:Array;
-
[Bindable]
-
private var collectionData:ArrayCollection;
-
-
private function init():void
-
{
-
collectionArray = [{first: 'Dave', last: 'Matthews'},
-
{first: 'Dave', last: 'Chappelle'},
-
{first: 'Amy', last: 'Grant'},
-
{first: 'Bilbo', last: 'Baggins'},
-
{first: 'Jessica', last: 'Tandy'},
-
{first: 'Jessica', last: 'Simpson'},
-
{first: 'Paris', last: 'Hilton'}];
-
collectionData = new ArrayCollection(collectionArray);
-
}
-
-
public function filter():void {
-
-
collectionData.filterFunction = filterFirst;
-
collectionData.refresh();
-
-
}
-
-
public function filterReset():void {
-
-
collectionData.filterFunction = null;
-
collectionData.refresh();
-
-
}
-
-
private function filterFirst(item:Object):Boolean
-
{
-
-
return item.first.match(new RegExp(searchField.text, 'i'))
-
-
//return( item['first'].indexOf( searchField.text )> -1 );
-
//return item['first'].match(new RegExp(string, “i”))
-
-
}
-
-
private function search():void
-
{
-
if(searchField.text !='')
-
{
-
filter()
-
}
-
else
-
{
-
filterReset()
-
}
-
}
-
]]>
Last 5 posts in as3
- Roman Numeral/Arabic Convertion AIR App - Johnny V Now Available - December 25th, 2008
- How to convert Roman Numerals and Arabic numbers in ActionScript 3 - December 17th, 2008
- Flash Player 10 Pure Flash Keyboard using SampleDataEvent - September 3rd, 2008
- Using Flash Player 10 to produce Dynamic Musical Notes - May 20th, 2008
- Flash Player 10 Dynamic Sound Generation - May 20th, 2008
Last 5 posts in Flex
- Adobe Evangelist Daniel Dura visits Travelocity - April 15th, 2008
- Yahoo Maps ActionScript 3.0 Released - February 11th, 2008
- Papervision 3D 2.0 / Great White Example - December 26th, 2007
- Tidbit #3 - testing additions to your code - Control Variable - November 28th, 2007
- Flash/Flex Tidbit #1 - October 18th, 2007
Josh Weatherspoon, A self-proclaimed millionaire who for some reason has to work as a Flash Developer, at Travelocity in Dallas(Southlake), TX.
1 person has left a comment
How would I implement this with XML instead of ArrayCollection?
Thanks!