Question : Flex Filters

Hello All,
I am filtering xml data usinf checkboxes and sliders(time(id:sldepTimeFilter) and fare(id:slider))
CheckBox filters and time filters are executing properly where as fare filter is not executing

please check the filtercode:

private function XMLDataFilters(item:Object):Boolean
                  {
                        //Stops and Refundable Filter
                        if (oneStop.selected == false && Number(item..onWardStops) == 1  )
                         return false;
                         if (twoStops.selected == false && Number(item..onWardStops) == 2  )
                         return false;
                         if (twoPlusStop.selected == false && Number(item..onWardStops) > 2  )
                         return false;
                         if (zeroStops.selected == false && Number(item..onWardStops) == 0  )
                         return false;
                         if(chkRef.selected == false && item..refundable == "YES")
                         return false;
                         if(chkNonRef.selected == false && item..refundable == "NO")
                         return false;
                         
                         //Time Filter
                         if((Number(item..departingHour) >= sldepTimeFilter.values[0]) && (Number(item..departingHour) <= sldepTimeFilter.values[1])){
                  return true;
                  }else{
                  return false;
                   }
                   
                   // Fare Filter
                   if((Number(item..finalFare) >= slider.values[0]) && (Number(item..finalFare) <= slider.values[1])){
                return true;
                       }else {
                  return false;
                }  
                  
                         
                  
                   return true;
                        
                  }

Answer : Flex Filters

Well in the lines "//TimeFilter and the following 5 lines you say "if its this then return true" ... "else return false" .... so the function call is finished here.

In the first segment you sort return false, if a check fails. You should have continued that logic.
Notice the inverted logic of the if statements ... in Time-Filter and Fare-Filter I only return false if the criteria is not valid.

I guess you would have to change your logic:
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:
    private function XMLDataFilters(item:Object):Boolean {
        //Stops and Refundable Filter
        if (oneStop.selected == false && Number(item..onWardStops) == 1)
            return false;
        if (twoStops.selected == false && Number(item..onWardStops) == 2)
            return false;
        if (twoPlusStop.selected == false && Number(item..onWardStops) > 2)
            return false;
        if (zeroStops.selected == false && Number(item..onWardStops) == 0)
            return false;
        if (chkRef.selected == false && item..refundable == "YES")
            return false;
        if (chkNonRef.selected == false && item..refundable == "NO")
            return false;

        //Time Filter
        if ((Number(item..departingHour) < sldepTimeFilter.values[0]) || (Number(item..departingHour) > sldepTimeFilter.values[1]))
            return false;

        // Fare Filter
        if ((Number(item..finalFare) < slider.values[0]) || (Number(item..finalFare) > slider.values[1]))
            return false;

        return true;
    }
Random Solutions  
 
programming4us programming4us