Specifications
CHAPTER 5
94
Using deferred creation
By default, containers create only the controls that initially appear to the user. Flex creates the container’s other
descendants if the user navigates to them. Containers with a single view, such as Box, Form, and Grid containers,
create all of their descendants during the container’s instantiation because these containers display all of their
descendants immediately.
Containers with multiple views, called navigator containers, only create and display the descendants that are
visible at any given time. These containers are the ViewStack, Accordion, and TabNavigator containers.
When navigator containers are created, they do not immediately create all of their descendants, but only those
descendants that are initially visible. Flex defers the creation of descendants that are not initially visible until the
user navigates to a view that contains them.
The result of this deferred creation is that an MXML application with navigator containers loads more quickly, but
the user experiences brief pauses when he or she moves from one view to another when interacting with the appli-
cation.
You can instruct each container to create their children or defer the creation of their children at application startup
by using the container’s
creationPolicy property. This can improve the user experience after the application
loads. For more information, see “About the creationPolicy property” on page 94.
You can also create individual components whose instantiation is deferred by using the
createComponentsFromDescriptors() method. For more information, see “Creating deferred components”
on page 98.
About the creationPolicy property
To defer the creation of any component, container, or child of a container, you use the creationPolicy property.
Every container has a
creationPolicy property that determines how the container decides whether to create its
descendants when the container is created. You can change the policy of a container using MXML or ActionScript.
The valid values for the
creationPolicy property are auto, all, none, and queued. The meaning of these
settings depends on whether the container is a navigator container (multiple-view container) or a single-view
container. For information on the meaning of these values see “Single-view containers” on page 95 and “Multiple-
view containers” on page 95.
The
creationPolicy property is not inheritable. This means that if you set the value of the creationPolicy
property to
none on an outer container, all containers within that container have the default value of the
creationPolicy property, unless otherwise set. They do not inherit the value of none for their creationPolicy.
Also, if you have two containers at the same level (of the same type) and you set the
creationPolicy of one of
them, the other container has the default value of the
creationPolicy property unless you explicitly set it.










