Specifications
CHAPTER 4
72
To use ordered creation, you set the creationPolicy property of a container to queued, as the following example
shows:
<?xml version="1.0"?>
<!-- optimize/QueuedPanels.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"/>
<mx:Button id="button1b"/>
</mx:Panel>
<mx:Panel id="panel2" creationPolicy="queued" width="100%" height="33%">
<mx:Button id="button2a"/>
<mx:Button id="button2b"/>
</mx:Panel>
<mx:Panel id="panel3" creationPolicy="queued" width="100%" height="33%">
<mx:Button id="button3a"/>
<mx:Button id="button3b"/>
</mx:Panel>
</mx:Application>
This adds the container’s children to a queue. Flash Player instantiates and displays all of the children within the
first container in the queue before instantiating the children in the next container in the queue.
For more information on ordered creation, see “Using ordered creation” on page 101.
Using deferred creation
To improve the start-up time of your application, minimize the number of objects that are created when the appli-
cation is first loaded. If a user-interface component is not initially visible at start up, create that component only
when you need it. This is called deferred creation. Containers that have multiple views, such as an Accordion,
provide built-in support for this behavior. You can use ActionScript to customize the creation order of multiple-
view containers or defer the creation of other containers and controls.
To use deferred creation, you set the value of a component’s
creationPolicy property to all, auto, or none. If
you set it to
none, Flex does not instantiate a control’s children immediately, but waits until you instruct Flex to
do so. In the following example, the children of the VBox container are not be instantiated when the application
is first loaded, but only after the user clicks the button:
<?xml version="1.0"?>
<!-- optimize/CreationPolicyNone.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><









