Flex, swapping items in a ListCollectionView

Tags: , ,

I believe in the next version of Flex (Code name Gumbo) this method is going to be available on ListBase, but here's how we can swap items on a ListCollectionView (which is extended by both ArrayCollection and XMLListCollection.

public function swapItemsAt(fromIndex:Number, toIndex:Number, collection:ListCollectionView):void{
			var fromItem:Object = collection.getItemAt(fromIndex);
			var toItem:Object = collection.getItemAt(toIndex);
 
			collection.setItemAt(fromItem, toIndex)
			collection.setItemAt(toItem, fromIndex);
 
		}

If you have any questions or comment, feel free to leave them below