Flex 滚动超过 10.000 像素
Flex Canvas 容器的尺寸限制为 10,000x10,000 像素。然而,我见过 Flex 应用程序的滚动距离超过 10,000 像素。知道如何做到这一点吗?
我想要滚动的内容已经是分段的,但我需要将这些分段添加到可以垂直滚动超过 10,000 像素的内容中。
The Flex Canvas container is limited to 10,000x10,000 pixels. Yet, I've seen Flex apps that are scrolling way more than 10,000 pixels. Any idea how this can be done?
The content I want to scroll is in pieces already, but I need to add those pieces to something that can scroll vertically more than 10,000 pixels.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您实际想要显示的内容,您可以将内容拆分为图块。这就是 Google 地图的工作原理,每次移动地图时,程序都会确定哪些图块在屏幕上可见并将其加载。地图上的任何标记或叠加层都会收到地图已移动的通知,并确定其新位置是。如果它们的位置超出屏幕,则可以将其从画布中删除。例如,Google 地图上缩放级别为 20 时所有图块的宽度为 (256 像素 * 2^20),等于总像素 268,435,456。
本质上,您只需要创建一个特殊的 Sprite 来跟踪它应该定位的实际 x,y 位置。每当容器移动时,您只需迭代所有子对象并确定将它们放在哪里。
因此,如果您有一个位于 (100, 20000) 的画布、一个位于 (300, 20100) 的精灵和一个位于 (640,408) 的窗口,那么您可以将其放置在 (200, 100) 处,并且它会在屏幕上可见。
更好的方法不是仅仅将可见设置为 true 或 false,而是当项目不在视图范围内时从画布中完全删除它们。
Depending on what you actually want to display you may be able to split your content into tiles. This is how Google Maps works, every time the map is moved the program determines which tiles are visible on the screen and loads them in. Any markers or overlays that are on the map are notified that the map has moved and determine where their new location is. If their location is off the screen they can be removed from the canvas. For example, the width of all the tiles at zoom level 20 on Google Maps is (256 pixels * 2^20) which equals 268,435,456 total pixels.
Essentially you just need to create a special Sprite that keeps track of the actual x,y location it is supposed to be positioned at. Any time the container moves you simply iterate through all of the child objects and determine where to put them.
So if you have a canvas that is positioned at (100, 20000), a sprite that is positioned at (300, 20100), and a window that is (640,408), you would place it at (200, 100) and it would be visible on the screen.
Instead of just setting visible to true or false a better approach would be to remove the items from the canvas entirely when they are not within the bounds of the view.