Monday, June 24, 2013

Adobe Flex 3 UI Components Lifecycle « Armindo Cachada's Blog: Struts 2, Adobe Flex and ATG



1) preInitialize: This event is raised when the component has just been created but none of the child components exist.
2) initialize: This event is raised after the component and all its children have been created but before any dimensions have been calculated.
3) creationComplete: This even is dispatched after all the component and its children have been created and after all the layout calculations have been performed.
4) applicationComplete: Dispatched after all the components of an application have been successfully created



<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
preinitialize="preInitialise()"
initialize="initialise()"
applicationComplete="applicationComplete()"
creationComplete="creationComplete()"
viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

[Bindable]
private var eventsCalled:ArrayCollection=new ArrayCollection();

public function preInitialise():void
{
eventsCalled.addItem({label: "preInitialise called", event: "preInitialise"});
}

public function initialise():void
{
eventsCalled.addItem({label: "initialise called", event: "initialise"});
}

public function creationComplete():void
{
eventsCalled.addItem({label: "creation complete called", event: "creationComplete"});
}


public function applicationComplete():void
{
eventsCalled.addItem("applicationComplete called");
}
]]>
</mx:Script>
<mx:TabNavigator width="400"
height="400">
<mx:Canvas label="tab1">
<mx:DataGrid id="datagrid"
dataProvider="{eventsCalled}"
top="10"
left="10"
width="300"/>
</mx:Canvas>
<mx:Canvas label="tab2">
<mx:Label text="This label is created only when it is displayed"
 creationComplete="creationComplete();"
 preinitialize="preInitialise();"
 initialize="initialise();"/>
</mx:Canvas>

</mx:TabNavigator>
</mx:Application>

No comments:

Post a Comment