In the last project I was working on we were developing more so based on Flex’s Application and component life cycles. Binding data within the life cycle helps eliminate the need for weak references as well as direct mxml bindings which ill admit I have been know to over use.
Recently a co-worker David Chang and I looked into the exact process Flex takes when initializing an application and its components and at what stages the data is available.
A Flex application goes through 4 distinct events when initializing an application.
- preinitialize
Dispatched at the beginning of the component initialization sequence, basically before anything else starts - initialize
Dispatched when the component has finished its constructions and has all initialization properties set, this is done after all the other components have initialized themselves. - creation complete
Dispatched when the component has finished its construction, property processing, measuring, layout, and drawing. This is done when all components have completed their creation. - application complete (where applicable)
Dispatched after the Application has been initialzed
This is all fine and dandy except I wanted to get a more concrete illustration of what exactly is available and when, so I wrote up this quick little poc to show me in the debugger at what point data is available for the application and his components.
Basic Application Life Cycle
<!--[CDATA[ /** * Here we have no access to component / children level information, * properties of any child in this application * */ private function onPreinitialize():void { trace("onPreinitialize() has no data will through an error in accessing component information" ); } /** * Here we can access information about our children components, * but not all information is accessible, notice width propety in text component * is set to 0 and not the true width becuase this information has not been set yet * */ private function onInitialize():void { trace("onInitialize() text.text=" + text.text + ", text.width=" + text.width + ", text.x=" + text.x ); } override protected function createChildren():void { super.createChildren(); trace("override createChildren() text.text=" + text.text + ", text.width=" + text.width + ", text.x=" + text.x ); } override protected function childrenCreated():void { super.childrenCreated() trace("override childrenCreated() text.text=" + text.text + ", text.width=" + text.width + ", text.x=" + text.x ); } override protected function commitProperties():void { super.commitProperties(); trace("override commitProperties() text.text=" + text.text + ", text.width=" + text.width + ", text.x=" + text.x ); } override protected function measure():void { super.measure(); trace("override measure() text.text=" + text.text + ", text.width=" + text.width + ", text.x=" + text.x ); } /** * At this point in the Application Life Cycle the children components * have been created, they have run through thier own life cycles * and all the information about them is available * */ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); trace("override updateDisplayList() text.text=" + text.text + ", text.width=" + text.width + ", text.x=" + text.x ); } private function onCreationComplete():void { trace("onCreationComplete() text.text=" + text.text + ", text.width=" + text.width + ", text.x=" + text.x ); } ]]-->






Hi,
can you please define at least how we can catch the total timing of load each process in the application livecycle process
for example .initlize process total time load