I have an array collection that I would like to limit to say 100 items. I tried setting up a filter function where the return was:
return (myAC.getItemIndex(item) > 100);
but the value was always -1. For whatever reason it couldn’t find the item, even though the item is definitely there.
I’m able to do this with a while loop:
while(myAC.length > 100) myAC.removeItemAt(100);
Is there another way I can accomplish this? Thanks!
Hmm, the best way I can think of is:
Of course, if you could control the size when the
ArrayCollectionis first constructed, that would be better.Note that you cannot directly manipulate the
sourceproperty of the object. From the docs of thesourceproperty ofArrayCollection: