2/7/2011 2:43:03 AM
Title:
spark list control vertical scroll position flickers
i have list control in flex 4, when i add items to it i want the scroll to reach the maximum vertical scroll position. the list has a renderer.
For this I have used:
list.layout.verticalScrollPosition = list.dataGroup.contentHeight - list.dataGroup.height;
The problem is that i want to show the max vertical scroll position as soon as the item is added to the list. So i have used in code:
arrCollection.addItem(myObject);
list.layout.verticalScrollPosition = list.dataGroup.contentHeight - list.dataGroup.height;
These two operation one after the other are does not solve the problem so i used callLater (two times) for setting verticalScrollPosition like:
callLater(function laterSetVerticalScroll():void
{
callLater(function laterSetVerticalScroll():void
{
list.layout.verticalScrollPosition = list.dataGroup.contentHeight - list.dataGroup.height;
});
});
DUE TO THIS LATER CALL THE SCROLL SHOWS A FLICKER (like it goes to vertical scroll 0, and then this method is called later), i very bad looking flicker on each additem.
I have already used list.ensureIndexIsVisible(arrColl.length - 1), this doesnt help either.
Please suggest a solution. Thanks
2/9/2011 6:05:47 AM
I think the best way would be to , see the last event which is triggered when a new item is added to list. Its kind of hit and trial. When a item is added to list many list events get fired like, initialized, changed etc. You can add your scrollbar positioning code to the last event fired.