[flexcoders] Re: removeItemAt combined with getItemAt - Manipulating an arrayCollection
Some more info, and I am getting closer. I am using the following function, but it returns a value of -1, out of bounds, regardless of what value I try to get the index of: public function remItem():void{ fields.removeItemAt(fields.getItemIndex({fieldTag: small, value:t})); } Remember that the arrayCollection looks like: private var fields:ArrayCollection = new ArrayCollection([{fieldTag: big, value:t}, {fieldTag: small, value: t}]); Does anybody know why getItemIndex would return a value of -1?
[flexcoders] Re: removeItemAt combined with getItemAt - Manipulating an arrayCollection
I believe its because you're passing in and looking for a new object. Even though it has the same properties as an object in the collection its not the same object. Try this: var smObj:Object = {fieldTag: small, value:t}; var bigObj:Object = {fieldTag: big, value:t}; public function remItem():void { fields.removeItemAt(fields.getItemIndex(smObj)); } HTH, Ben --- In flexcoders@yahoogroups.com, michaelmatynka [EMAIL PROTECTED] wrote: Some more info, and I am getting closer. I am using the following function, but it returns a value of -1, out of bounds, regardless of what value I try to get the index of: public function remItem():void{ fields.removeItemAt(fields.getItemIndex({fieldTag: small, value:t})); } Remember that the arrayCollection looks like: private var fields:ArrayCollection = new ArrayCollection([{fieldTag: big, value:t}, {fieldTag: small, value: t}]); Does anybody know why getItemIndex would return a value of -1?
RE: [flexcoders] Re: removeItemAt combined with getItemAt - Manipulating an arrayCollection
Each time you use {}, you instantiate a unique new object which of course is not findable in the collection. You can use find() for that though. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of michaelmatynka Sent: Monday, June 04, 2007 4:14 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: removeItemAt combined with getItemAt - Manipulating an arrayCollection Some more info, and I am getting closer. I am using the following function, but it returns a value of -1, out of bounds, regardless of what value I try to get the index of: public function remItem():void{ fields.removeItemAt(fields.getItemIndex({fieldTag: small, value:t})); } Remember that the arrayCollection looks like: private var fields:ArrayCollection = new ArrayCollection([{fieldTag: big, value:t}, {fieldTag: small, value: t}]); Does anybody know why getItemIndex would return a value of -1?