After watching a Lynda.com tutorial realized I didn't have to do as much work to filter data.
the filterFunction is a public property of the ICollectionView witch is the class that the ArrayCollection extends from.
So this function/method is accessible to a ArrayCollection.
Actionscript:
-
<blockquote />
-
<blockquote><?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: 'Amy', last: 'Grant'},
-
{first: 'Bilbo', last: 'Baggins'},
-
{first: 'Jessica', last: 'Tandy'},
-
{first: 'Paris', last: 'Hilton'}];
-
collectionData = new ArrayCollection(collectionArray);
-
}
-
-
public function filter():void {
-
-
//pass my filter function to the method w/ no ()
-
// you must also refresh it
-
collectionData.filterFunction = filterFirst;
-
collectionData.refresh();
-
-
}
-
// function see's if the searchField's text is equal to the "first" object of the collectionData
-
-
//if true it show results, if false it shows nothing
-
private function filterFirst(item:Object):Boolean
-
{
-
return (item.first == searchField.text)
-
-
}
-
]]>
Problems w/ this:
- I have not found a way to match with just typing in "Da" and it is case-sensitive
- When you type in a non-matching string it will not reset to beginning state. (I'm sleepy so maybe that's why I can't figure it out.)
Last 5 posts in actionscript
- Using Flash Player 10 to produce Dynamic Musical Notes - May 20th, 2008
- Flash Player 10 Dynamic Sound Generation - May 20th, 2008
- How to compile and examples for Flash Player 10 or ASTRO BETA - May 16th, 2008
- How to use Bitmap and BitmapData in ActionScript 3 - v2 - April 23rd, 2008
- How to use Bitmap and BitmapData in ActionScript 3 - v1 - April 21st, 2008
Last 5 posts in as3
- 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
- How to load Pixel Bender in Flash Player 10 - May 19th, 2008
- How to compile and examples for Flash Player 10 or ASTRO BETA - May 16th, 2008
Last 5 posts in flash
- 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
- How to load Pixel Bender in Flash Player 10 - May 19th, 2008
- How to compile and examples for Flash Player 10 or ASTRO BETA - May 16th, 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.
Horaayy..there are 3 comment(s) for me so far ;)
Try looking into Regular Expressions, which make it easy to have case-insensitive searches with fragments of the word.
return (item.first == searchField.text)
becomes:
return item.first.match(new RegExp(searchFiel.text, "i"))
The second parameter tells the RegEx to ignore case sensitivity.
Thanks I'm working on finding that out right now
Usefull info what I was searching for. Thank you again.