Thursday, January 22, 2009

Deferred instantiation in mx:Viewstacks

I use a number of Viewstacks in our app and was worried that they would consume a lot of memory since it appeared that all of their children were being instantiated whether or not they were displayed. It turns out that only the top-level children are instantiated, not the grandchildren. That's good news.

Here's the revealing comment from Viewstack.as


// If the policy is ContainerCreationPolicy.AUTO, ViewStack
// instantiates its children immediately, but not any grandchildren.
// The children of the selected child will get created in
// instantiateSelectedChild().