I have an ArrayCollection that I want to have all null or empty values removed.
What line in the code might accomplish this?
I have an ArrayCollection that I want to have all null or empty values removed.
What line in the code might accomplish this?
This is the faster way in terms of performance:
<mx:Script><![CDATA[
public function cleanArrayCollection(collection:ArrayCollection):ArrayCollection{
var currentArray:Array = null;
var newCollection:ArrayCollection = new ArrayCollection();
for(var i:int = 0; i < collection.length; i++){
currentArray = collection.getItemAt(i);
if(currentArray != null && currentArray.length != 0){
newCollection.addItem(currentArray);
}
}
return newCollection;
}
]]></mx:Script>
Edit: Removed critical bugs in logic.