Flex viewstack keeps redrawing invisible child, how to fix?

903 views Asked by At

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.

2

There are 2 answers

0
MysticEarth On BEST ANSWER

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
Kai Arnold On

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.