Flex viewstack不断重绘不可见的子项,如何修复?
情况:我有一个 ViewStack
和 2 个子组件(都是 Panel
类型)。 应用程序以子级 1 作为 SelectedChild
开始。
单击按钮后,子项 2 就是 SelectedChild。之后,我返回到孩子 1,即 SelectedChild。
当我在 Flash Player 中单击显示重绘区域
时,我可以看到子级 2 一直在重绘(子级 2 中有一些移动的对象)。我怎样才能防止这种情况发生?或者这只能通过实际删除不可见的(在本例中为子 2)子项来完成?
为什么我想实现这个目标? Child 2 将包含相当多的数据(flv、图像等),当像现在这样缓存时,它会减慢我的应用程序的速度。
The situation: I've got a ViewStack
with 2 children (both of type Panel
).
The application starts with child 1 as the SelectedChild
.
With a click on a button, child 2 is the SelectedChild. After that, I return to child 1 being the SelectedChild.
When I click Show Redraw Regions
in the Flash Player, I can see child 2 being redrawn the whole time (i've got some moving objects in child 2). How can I prevent this from happening? Or can this only be done with actually removing the invisible (in this case child 2) child?
Why I want to achieve this? Child 2 will contain pretty much data (flv's, images, etc.) and when it's being cached like what happens now, it will slow down my application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Flash 效率低下的一个主要原因可能来自显示列表中的不可见对象。它们不仅会继续导致重绘区域刷新(“红色矩形”),而且每当玩家需要遍历显示列表树时,它们都会对 Flash 处理施加 CPU 惩罚。当显示列表较大时,即使您没有任何 MouseEvent 侦听器,鼠标悬停的成本也明显更高。任何包含超过几千个对象的显示列表都会开始感到痛苦。
长话短说,有时性能要求您编写自己的“可见性管理器”来将对象交换进出父层次结构,作为切换 DisplayObject.visible 的替代方法。
A major source of inefficiency in Flash can come from invisible objects on your display list. Not only do they continue to cause redraw region refreshes ("red rectangles"), they impose CPU penalties on Flash processing whenever the player needs to traverse the display list tree. Mouseovers are notably more expensive, even if you don't have any MouseEvent listeners, when the display list is larger. Any display list containing more than a couple thousand objects can start to feel the pain.
Long story short, sometimes performance dictates that you write your own "visibility manager" to swap objects in and out of the parent hierarchy as an alternative to toggling DisplayObject.visible.
我已经弄清楚了:唯一的方法似乎是真正删除孩子,或者它是移动/动画内容。
像 Amargosh 提到的那样调用
video.stop()
、animation.stop()
也应该有所帮助。I've figured it out: the only way seems to actually remove the child, or it's moving/animated content.
Calling
video.stop()
,animation.stop()
like Amarghosh mentioned should help too.