What's the best-approach to swap to elements in a Flex Array Collection?
I am binding a ArrayCollection as a dataprovider to combo-box. Selecting a row, should move the object to the top of the combo-box list, 开发者_Python百科and move the top-object to selected object's position.
I would do this instead:
dataProvider.addItemAt(dataProvider.removeItemAt(selectedIndex), 0);
The only problem is that this would make the combobox rebind twice, but for simplicity sake it shouldn't be an issue.
Tried setItemAt?
This worked!
var temp:Object = myDataProvider.getItemAt(0);
var pos:int = myDataProvider.getItemIndex(selected);
myDataProvider.setItemAt(selected,0);
myDataProvider.setItemAt(temp,pos);
myDataProvider.refresh();
精彩评论