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:
preinitializeThe component's been instantiated but hasn't yet created any child components.
initializeThe component has created child components but has not yet laid out those components.
creationCompleteThe 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access