
You've just finished developing your killer Macromedia Flex app and are ready to deliver it to your users. However, you feel like it could use just a few finishing touches. One area you can look into improving is the initialization experience of your application.
By default, Flex will display the Loading progress bar while it initializes the application. Only after all of the components in the application have been initialized and laid out will Flex display any portion of the application. Using a concept called progressive layout, you can customize this experience.
In this article, I will explain how you can use progressive layout to force your content to display after it has been initialized, instead of waiting until the entire application has finished initializing. You can control the order in which your content is displayed. If you are using the WebService, HTTPService, or RemoteObject components, you can display the results of the request as they come back from the server. To add even more slickness to your application, I'll show you how to incorporate effects to the initializing experience.
To complete this tutorial you will need to install the following software and files:
Familiarity with Macromedia Flex and some experience building Flex applications. Ideally, you should have built at least one simple Flex application. If you haven't, see Creating Your First Flex Application by Robert Crooks.
The Flex manual explains the component instantiation and creation policy in detail. View the "Applying Deferred Instantiation" section in the Developing Flex Applications manual for this information. I will briefly provide some context and background on component instantiation as it pertains to progressive layout.
When Flex first initializes the application, it performs a series of steps on each component and container. First, it loads all of the component's properties, applies them, and sets up the component's internal state. It then asks the component to measure how big it wishes to be. Next, the component or container is sized and positioned by its parent container. Finally, the component is displayed.
Developers have some control over when this instantiation process
occurs. All containers have a creationPolicy property that dictates
how the container should instantiate itself. In Flex 1.0 the possible
values were all, auto, and none. For Flex 1.5, we've added a new
value called queued.
all means that a container immediately creates its
children. auto, which is only relevant to navigators
like TabNavigator and Accordion, means that a container creates its
children when they are needed. none means that the container doesn't create its own
children. It would then be up to the developer to programmatically
create that container's children. queued means that the container's children are not
immediately created. Instead, they are added to a creation queue.
The application processes each item in the queue, one after another.
After the item in the queue has been processed, it is displayed immediately.
The application then processes the next item in the creation queue. Jason Szeto is a software engineer on the Macromedia Flex framework team. Prior to Macromedia, he worked at several small software companies doing software and web application development. At his previous company, Jason developed lipsyncing algorithms and toolkits for animated 2D Flash characters on the web. In his spare time, he enjoys cooking and playing basketball. However, his attempt to combine the two interests failed when his basketball stew turned out too stringy.