blog
{Some Little News}
VR
{Virtual Reality}
media
{Photos + Videos}
code
{Websites + Apps}
5core
{Five Core}
Multiple filter [Flex Example]
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:
[RAW]
id="fm_Ex_Filter_2031413492"
class="flashmovie"
width="573"
height="268">
[/RAW]
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 ;).








WOOOT thanks! This just saved my day!! I encountered the same problem with sorting data when its provided by MySQL.. It works now though! Thanks again peace out