Try doing something like this:

var obj:Object = mySortedArray.getItemAt(index);
var originalIndex:int = mySortedArray.list.getItemIndex(obj);
mySortedArray.list.removeItemAt(originalIndex);

I didn't test the code. But the idea behind it is that a ListcollectionView
holds a pointer to the IList it's wrapping so you have access to it. All you
have to do is get the object you want to remove, find it's index in the
wrapped IList and use that index to remove it, again from the wrapped IList.

Haykel Ben Jemia

Allmas
Web & RIA Development
http://www.allmas-tn.com




On Fri, Nov 21, 2008 at 6:51 PM, Amy <[EMAIL PROTECTED]> wrote:

>   --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, bjorn
> <[EMAIL PROTECTED]> wrote:
> >
> > I experienced some problems with ArrayCollection's removeItemAt().
> It seemed
> > to work... randomly.
> >
> > Tucked away in the documentation i found this little gem:
> > "Note: If you use the ICollectionView interface to sort or filter a
> > collection, do not use the IList interface to manipulate the data,
> because
> > the results are indeterminate."
> >
> > My problem, of course, was that I had a sort on the ac, and that I
> used
> > IList's removeItemAt().
> >
> > I don't understand the rationale behind this, maybe someone can
> explain to
> > me why it's difficult to implement removeItemAt() on a
> > sorted ArrayCollection ... I mean, I _am_ working with sorted data
> here, so
> > when I say index 11 I mean index 11 on the sorted data. That's the
> data I
> > see, that's the data I'm using, I don't need to know anything about
> the
> > underlying Array and the element's _real index_ ....the
> ArrayCollection
> > knows which element this refers to in the underlying Array, so there
> > shouldn't be a problem ...?
> >
> > Anyway, given the restraints we're working with here - what is the
> best way
> > to approach this? I need to be able to remove items from a sorted
> > ArrayCollection - any best practices?
>
> I usually use either a one or more other ArrayCollections or
> ListCollectionViews with a pointer to the same data to do filtering
> and sorting on. Although often that's just because I want to
> preserve the original order as much as anything.
>
>  
>

Reply via email to