开发者

Flex viewstack keeps redrawing invisible child, how to fix?

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 inv开发者_开发问答isible (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.


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.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜