Some Little News

  • Home
  • Contact Me
  • Categories
    • css
    • flash
    • Flex 4
    • General
    • JavaScript
    • Panorama
    • Personal
    • PHP
    • Reflections
    • Resources
    • Tips&Tricks
    • Web resources
    • Web services
  • teocomi's VR
  • teocomi.com
  • teocomi Flash
  • Subscribe via RSS

Multiple filter [Flex Example]

December 12th, 2009  |  Published in Flex 4

In this example I show an easy way to filter an ArrayCollection with multiple conditions, it can also be applied to XMLListColletions. Filters are given by the DropDownLists and the result is shown in the DataGrid.

Source here:

Get Adobe Flash player

I created this function to filter the data, it loops through the files and if all the conditions are respected returns true:

[code lang="as3"]
private function peopleFilter(item:Object):Boolean {
var risp:Boolean=new Boolean;
if (sexFilter.selectedIndex == 0 || item.sex == sexFilter.selectedItem) {
if (hairFilter.selectedIndex == 0 || item.hairColor == hairFilter.selectedItem) {
if (ageFilter.selectedIndex == 0 || item.age >= ageFilter.selectedItem) {
return true
}
}
}

return false;
[/code]

the same can be done in a more professional way, creating an ArrayCollectionExtended Class as explained in this tutorial, but afterwards I had some problems passing the data from MySQL into the new ArrayCollectionExtended.

So, maybe you prefer the easy way too ;).



Share this post on:
twitter facebook stumbleupon reddit delicious friendfeed digg google myspace

Leave a Response

CAPTCHA Image
CAPTCHA Audio
Refresh Image

Tag Cloud

360 actionscript 3 adobe blog css data database download easy email example excel facebook firefox flash flex Flex 4 free google html html5 image learn local mysql new online Panorama Personal PHP plugin register resize save server service spark teocomi test tutorial web website windows wordpress xls

WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.



©2010 Some Little News
Powered by teocomi using the Gridline Lite theme.