Wednesday, 12 October 2011

Remove items from Flex ArrayCollection

var alerts:ArrayCollection = new ArrayCollection();

for (var i:int = alerts.length; i > 0; i--)
{
   var alert:Alert = alerts.getItemAt(i-1) as Alert;
   if (alert.parentName == parentName)
   {
      alerts.removeItemAt(i-1);
   }
}

Note: alerts.length is initialized once and thus does not vary, on the contrary of:

for (var i:int =0; i < alerts.length; i++)