Specifications
CHAPTER 5
102
In this example, the image on the left shows the application after the first container is populated with its children
and data, but before the remaining four containers are populated. The image on the right shows the final state of
the application.
If this application did not use ordered creation, Flex would not display anything until all components in all five of
the containers were created, resulting in a longer perceived start-up time.
To gradually display children of each container, you add them to an instantiation queue. The “Adding containers
to the queue” on page 102 section describes how to add containers to the queue so that you can improve perceived
layout performance of your Flex applications.
Adding containers to the queue
You can add any number of containers to the instantiation queue so that their contents are displayed in queue
order. To add a container to the instantiation queue, you set the value of the container’s
creationPolicy property
to
queued. Unless you specify a queue order, containers are instantiated and displayed in the order in which they
appear in the application source code.
In the following example, the Panel containers and their child controls are added to the instantiation queue. To
the user, each Panel container appears one at a time during the application startup. The perceived startup time of
the application is greatly reduced. The panels are created in the order that they appear in the source code (panel1,
panel2, panel3):
<?xml version="1.0"?>
<!-- layoutperformance/QueuedCreationPolicy.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Panel id="panel1" creationPolicy="queued" width="100%" height="33%">
<mx:Button id="button1a" label="Button 1A"/>
<mx:Button id="button1b" label="Button 1B"/>
</mx:Panel>
<mx:Panel id="panel2" creationPolicy="queued" width="100%" height="33%">
<mx:Button id="button2a" label="Button 2A"/>










