If you're rolling your own, that's the way. -TH
--- In flexcoders@yahoogroups.com, "blc187" <[EMAIL PROTECTED]> wrote: > > I have an ArrayCollection of objects that I am receiving updates on. > On update, I get the updated item as an argument and I need to > replace the old item in the list. > Right now I am cycling through the ArrayCollection until i find the > id of the item and returning the index, then replacing the item at > that index. > Any thoughts on a better way to do this? > > > public var itemCollection:ArrayCollection; > > public function onUpdateReceived(newItem:Object):void { > findIndex(newItem); > if(index > -1) > itemCollection.setItemAt(newItem, index); > } > > public function findIndex(newItem:Object):Number { > > for each(var itemInCollection:Object in itemCollection){ > if(itemInCollection.id == newItem.id) return > itemCollection.getItemIndex(itemInCollection); > } > > return -1; > } >