开发者

Scroll flex spark datagroup to maximum amount programmatically

I have a spark skinnable component which contains a datagroup with images. The datagroup is scrolled by hovering the mouse over it. Everything works fine except one thing: after I change the datagroup provider, I need to scroll down automatically. The problem is the images are not loaded immediately after I set the provider so (contentHeight - height) does not yet represent the actual maximum scrolling position. Is ther开发者_如何学JAVAe an easy way of telling the datagroup to scroll down as its content loads? Because the workaround seems to be not so straightforward.

This is the code for scrolling(thumbnailStrip is my datagroup):

private function thumbnailStrip_mouseMoveHandler(evt:MouseEvent):void {

            var fr:Number = (thumbnailStrip.contentHeight - thumbnailStrip.height) / thumbnailStrip.height;
            var scroll:Number = fr * evt.stageY - fr * this.y;

            var ms:Number = maxScroll();
            if(scroll > ms) scroll = ms;

            thumbnailStrip.verticalScrollPosition = scroll;
        }

        private function maxScroll():Number {
            return thumbnailStrip.contentHeight - thumbnailStrip.height;
        }

Thanks, Calin


thumbnailStrip.layout.verticalScrollPosition += thumbnailStrip.layout.getVerticalScrollPositionDelta(NavigationUnit.END);

This may have to run a few times to get all the way to the bottom.It's supposed to return the difference between the current scroll position and the "end" of the scroll position. As things load, I'd just keep calling this in a "callLater".

btw, there's a bug for this: http://bugs.adobe.com/jira/browse/SDK-25740 not sure if it's fixed in 4.5, ugly workaround here: http://flexponential.com/2011/02/13/scrolling-to-the-bottom-of-a-spark-list/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜