I have a Flex question, which isn\'t as easy as it seems at first.
At least I\'m struggling since 1 week with it.
I have prepared a test case and a screensho
Try to operate ArrayCollection's source property the following way:
= 0; i--)
{
for (j = data.length - 1; j >= 0; j--)
{
if (sourceData[i] == data[j])
continue found1;
}
var index:int = _data.getItemIndex(sourceData[i]);
if (index > -1)
_data.removeItemAt(index); // remove visible items
else
sourceData.splice(i, 1); // remove hidden (filtered) items
}
// 2) add items appeared in data to _data
found2: for (j = 0; j < data.length; j++)
{
for (i = 0; i < sourceData.length; i++)
{
if (sourceData[i] == data[j])
continue found2;
}
_data.addItem(data[j]);
}
}
private function radioClicked(event:Event):void
{
switch (filterGroup.selection)
{
case allButton:
{
_data.filterFunction = null;
break;
}
case oddButton:
{
_data.filterFunction = filterOdd;
break;
}
case evenButton:
{
_data.filterFunction = filterEven;
break;
}
}
_data.refresh();
}
]]>
And a couple of advices on using RadioButton and RadioButtonGroup:
change instead.RadioButtonGroup it is better to refer group rather than groupName. It gives you possibility to check problems on compile time (imagine some misprints in group name).