以编程方式将 Flex Spark 数据组滚动到最大数量
我有一个 Spark 可换肤组件,其中包含带有图像的数据组。将鼠标悬停在数据组上即可滚动数据组。一切正常,除了一件事:更改数据组提供程序后,我需要自动向下滚动。问题是在我设置提供程序后图像不会立即加载,因此 (contentHeight - height)
尚不代表实际的最大滚动位置。有没有一种简单的方法可以告诉数据组在其内容加载时向下滚动?因为解决方法似乎并不那么简单。
这是滚动的代码(thumbnailStrip 是我的数据组):
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;
}
谢谢, 卡林
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 there 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能需要运行几次才能一直到达底部。它应该返回当前滚动位置和滚动位置“结束”之间的差异。当事情加载时,我会继续在“callLater”中调用它。
顺便说一句,这里有一个错误: http://bugs.adobe.com/jira/browse /SDK-25740 不确定它是否在 4.5 中修复,这里是丑陋的解决方法:http://flexponential.com/2011/ 02/13/滚动到 Spark 列表底部/
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/