/ Published in: ActionScript 3
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
override protected function scrollPositionChanged():void {
if (!useVirtualLayout) {
super.scrollPositionChanged();
return;
}
var g:GroupBase = target;
if (!g)
return;
updateScrollRect(g.width, g.height);
var n:int = g.numElements - 1;
if (n < 0) {
setIndexInView(-1, -1);
return;
}
var scrollR:Rectangle = getScrollRect();
if (!scrollR) {
setIndexInView(0, n);
return;
}
var y0:Number = scrollR.top;
var y1:Number = scrollR.bottom - .0001;
if (y1 <= y0) {
setIndexInView(0, n);
return;
}
var i0:int, i1:int;
if (y0 < 0) {
i0 = 0;
i1 = yToIndex.length - 1 > g.height ? yToIndex[g.height + 1] : g.numElements - 1;
setIndexInView(i0, i1);
return;
}
if (y1 < yToIndex.length - 1) {
i0 = yToIndex[Math.floor(y0)];
i1 = yToIndex[Math.ceil(y1)];
} else {
if (yToIndex.length - 1 - g.height < 0)
i0 = 0;
else
i0 = yToIndex[yToIndex.length - 1 - g.height];
i1 = yToIndex[yToIndex.length - 1];
}
setIndexInView(i0, i1);
//invalidate display list only if we have items that are not already renderered
if (i0 < currentFirstIndex || i1 > currentLastIndex) {
g.invalidateDisplayList();
}
}
URL: http://corlan.org/?p=2987
Comments
 Subscribe to comments
                    Subscribe to comments
                
                