Where did you find that note? Can you perhaps post a sample code with the problem? I tried to reproduce the problem without success. I have this test app that is working perfectly:
------------------------------------------------ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> <mx:ArrayCollection id="ac"> <mx:String>3</mx:String> <mx:String>8</mx:String> <mx:String>1</mx:String> <mx:String>4</mx:String> <mx:String>7</mx:String> <mx:String>2</mx:String> </mx:ArrayCollection> <mx:ListCollectionView id="lcv" list="{ac}"> <mx:sort> <mx:Sort> <mx:SortField name="{null}" numeric="true" /> </mx:Sort> </mx:sort> </mx:ListCollectionView> <mx:HBox> <mx:List id="list" dataProvider="{lcv}" /> <mx:List dataProvider="{ac}" /> </mx:HBox> <mx:Button label="remove" enabled="{list.selectedIndex >= 0}" click="lcv.removeItemAt(list.selectedIndex)" /> </mx:Application> ------------------------------------------------ Haykel Ben Jemia Allmas Web & RIA Development http://www.allmas-tn.com On Fri, Nov 21, 2008 at 6:21 PM, 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? > > Bjørn > -- > ========================== > http://www.juicability.com - flex blog > http://www.expressionengine.no - ExpressionEngine; the world's most > flexible cms > >