Specifications
CHAPTER 5
98
Creating deferred components
When you set a container’s creationPolicy property to none, components declared as MXML tags inside that
container are not created. Instead, objects that describe those components are added to an Array. These objects
are called descriptors. You can use the
createComponentsFromDescriptors() method to manually instantiate
those components. This method is defined on the Container base class.
Using the createComponentsFromDescriptors() method
You use the createComponentsFromDescriptors() method of a container to create all the children of a
container at one time.
The createComponentsFromDescriptors() method has the following signature:
container.createComponentsFromDescriptors(recurse:Boolean):Boolean
The recurse argument determines whether Flex should recursively instantiate children of the components. Set
the parameter to
true to instantiate children of the components, or false to not instantiate the children. The
default value is
false.
On a single-view container, calling the
createComponentsFromDescriptors() method instantiates all controls
in that container, regardless of the value of the
creationPolicy property.
In navigator containers, if you set the
creationPolicy property to all, you do not have to call the
createComponentsFromDescriptors() method, because the container creates all controls in all views of the
container. If you set the
creationPolicy property to none or auto, calling the
createComponentsFromDescriptors() method creates only the current view’s controls and their descendents.
Another common usage is to set the navigator container’s
creationPolicy property to auto. You can then call
navigator.getChildAt(n).createComponentsFromDescriptors() to explicitly create the children of the n-
th view.
The following example does not instantiate any of the buttons in the HBox container when the application starts
up, but does when the user changes the value of the
creationPolicy property. The user initiates this change by
selecting all from the drop-down list.
<?xml version="1.0"?>
<!-- layoutPerformance/ChangePolicy.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="appInit()">
<mx:Script><![CDATA[
[Bindable]
public var p:String;
private function appInit():void {










