> > > Flex – preinitialize, initialize and creationcomplete | Adobe Flex Tutorial #6

Flex – preinitialize, initialize and creationcomplete | Adobe Flex Tutorial #6

Flex life cycle phases – preinitialize, initialize and creationComplete

We can develop applications without knowing the life cycle phases also but if we know these things then we can do our coding in a better way. Then we will know where to place the codes and all. So here we are going to discuss about the life cycle phases of Flex applications:

Flex – preinitialize, initialize, creationComplete and applicationComplete.

flex-preinitialize, initialize and creation complete


Preinitialize is an event, it will generate at the early stage of an application and it will create actually when the application is attached to the parent container at .At that time none of the components will initialize and none of the children also create.So, preinitialize is the first phace inthe flex application life cycle.

At the time when the flex dispatches the preinitialize event none of the children or components not yet been created.

And the event type is :



It will occur after the preinitialize.The initialize dispatch when the intitialization of that application is completed.And after this the immediate children of the application will create.

When initilize event will occur is based on the containers creation policy.

Flex dispatches the initialize event for a container after it attaches all the container’s direct child controls and the container’s initially required children have dispatched a preinitialize event.

The initlize will occur after the preinitialize at that time the applications or containers initial properties will set.And at that time the height and width of the application is not yet calculated so the position properties won’t set during the initialization phase of the application life cycle.

The initialize event is useful for configuring a container’s children.

This event is dispatched after preinitialize phase. And flex uses initialize tio set the internal properties of the components.


The creation complete event will dispatch when the application,all the immediate children and their children are initialized and created .And in creatinComplete those components or objects needed at the begining and those are done with processing are drawn to the screen.

Actually the creationcomplete won’t use for setting the layout, because it will take more time to process.

The creationComplete Event is dispatched only when the construction,properthy processing , the layout and drawing is completed.


Dispatched after the Application has been initialized, Actually the applicationComplete is processed by the LayoutManager, and after the processing it will get automatically attached to the display list of the corresponding application. Actually this is the last event of application creation life cycle and it make sure that the application loaded completely .

The following is an example for the different life cycle phases of a flex application . And it demonstrate when these events will occur and when we have to use theseĀ  eventsĀ  in an application

    width="640" height="480"
    applicationComplete="teackEvent(event)" >
      import mx.events.FlexEvent;
      import flash.utils.getTimer;

      private var trackTxt:String = "";

      private function trackEvent(event:FlexEvent):void
        trackTxt += (event.type + " event occured at "
            + flash.utils.getTimer() + "ms" + "\n");
  <mx:Panel x="0" y="0" width="640" height="480" layout="absolute"
      title="Life Cycle Events">
    <mx:TextArea x="10" y="10" width="309" height="259"
        editable="false" id="trackReport" text="{trackTxt}"/>

The output will look like this:

flex-preinitialize, initialize and creation complete

So,whan a flex applicationis executing first it will call the preinitialize even then initialize, creationComplete and applicationComplete respectively.

The following two tabs change content below.

Aravind Radhakrishnan

A smart working techie who is currently working as HTML 5 & Java developer, having sound knowledge in Adobe Flex and Flash. Born and brought up in Kerala. Currently working in Chennai

One thought on “Flex – preinitialize, initialize and creationcomplete | Adobe Flex Tutorial #6

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.