Understanding the Component Life Cycles

All Flex components, including Application, have a common, standard life cycle. These life cycles are most easily described and understood from the view of the events they dispatch. We are primarily concerned with the following three major events in a component life cycle:

preinitialize

The component's been instantiated but hasn't yet created any child components.

initialize

The component has created child components but has not yet laid out those components.

creationComplete

The component has been completely instantiated and has laid out all child components.

The events always occur in this order: preinitialize, initialize, and creationComplete.

Note

See Chapter 19 for more details on component life cycles and events.

Components are always created from descriptors. The use of descriptors allows the Flex framework a lot of flexibility in terms of how and when it instantiates components. Each component that can contain child components will have a list of descriptors for the child components. As you’ll see in Chapter 10, you can control the creation policy for some components. In those cases, if you were to defer instantiation of child components, such a component would dispatch a preinitialize event right away, but it would not dispatch the initialize event until the code explicitly created the child components from the descriptors.

The initialize event occurs when the child components have been created. However, at this point the layout of the child ...

Get Programming Flex 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.