You'd have to scan the arraycollection.  I wouldn't use an AC in a
filter function, I'd probably use an object map indexed by fieldTag so
you can remove faster.  The filter function should use for..in to
iterate the fields.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of michaelmatynka
Sent: Saturday, June 02, 2007 8:24 PM
To: [email protected]
Subject: [flexcoders] removeItemAt combined with getItemAt -
Manipulating an arrayCollection

 

Hello All, great group here. Delighted to have stumbled upon it.

I have an arrayCollection which is used to pass info to a function which
filters an XMLList. 
The arrayCollection, in an ideal world, would change in size and content
based on user 
selections of a series of checkboxes. (i.e. check a box, and add another
filter criteria to 
the arrayCollection, uncheck the box and the criteria gets removed and
the filter rerun).

Here is the arrayCollection:
[Bindable]
public var fields:ArrayCollection = new ArrayCollection([{fieldTag:
"big", value:"t"}, 
{fieldTag: "small", value: "t"}]);

The function in this case would return all items whose node named "big"
AND "small" 
matched "t". 

How can I use removeItemAt and getItemAt in a function to pass in 1
argument to remove 
an element of the arrayCollection. Say for example I wanted to remove
the element whose 
fieldTag was "big" but I did not know where it was in the
arrayCollection. Something like 
this worked when the array was not multidimensional:

fields.removeItemAt(arr.getItemIndex("big");

I would love to put this mess to bed, can anyone shed some light on
this?

Thanks a bunch.

 

Reply via email to