I have a simple list in Flex that is populated every N seconds by a dataprovider. My goal is to avoid scrolling the list after the dataprovider has been changed.
So, before I populate the list, I save the selectedIndex, and once the dataProvider is filled, I call:
list.selectedIndex = index;
list.scrollToIndex(index);
Trouble is that this moves the selected item of the list to the top.
The solution would be to get the index of the first element displayed in the list: but I have no idea on how to get that. Any clue?
Perhaps something like: list.getIndexFirstVisibleElement()
You haven’t mentioned if you’re using Flex 4, but if you are you might want to look into
ensureIndexIsVisible.You can find an example here: http://blog.flexexamples.com/2010/05/12/scrolling-to-a-specific-index-in-a-spark-list-control-in-flex-4/.