zxhDaniel 发表于 2013-2-5 09:20:59

[转]FLEX的初始化顺序

<span style="font-family: Verdana, Helvetica, Arial, sans-serif; border-collapse: collapse; color: #444444;"><span style="color: #444444;">From:http://blog.csdn.net/dante_k7/archive/2009/06/18/4275381.aspx
FLEX组件在建立的时候都会经历四个事件:preinitialize , initialize , creationComplete 和 updateComplete(updateComplete事件在任何改动视觉的情况下都会发生,不是初始化时独有的)。

下面的例子检测在嵌套和平行的情况下,各个组件的事件抛出顺序。<div style="margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 10px; padding-right: 0px; padding-bottom: 5px; padding-left: 10px; line-height: normal; width: 586px; background-color: #f7f7f7; background-position: 0px 0px; border: 1px solid #cccccc;" class="blockcode"><div style="line-height: normal; padding: 0px; margin: 0px;">
[*]<?xml version="1.0" encoding="utf-8"?>
[*]<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
[*]                                preinitialize="showEvent(event)"
[*]                                initialize="showEvent(event)"
[*]                                creationComplete="showEvent(event)"
[*]                                updateComplete="showEvent(event)">
[*]        
[*]        <mx:script>
[*]                  <!--[CDATA[
[*]                import flash.utils.getTimer;
[*]                private function showEvent(event:Event):void {
[*]                       trace(flash.utils.getTimer().toString()+" >> "+event.currentTarget.name+" "+event.type);
[*]                }
[*]                 ]]-->
[*]        </mx:script>
[*]        
[*]        <mx:Canvas id="canv1"
[*]                           preinitialize="showEvent(event)"
[*]                           initialize="showEvent(event)"
[*]                           creationComplete="showEvent(event)"
[*]                           updateComplete="showEvent(event)">
[*]                
[*]                <mx:Button id="btn1"
[*]                                   preinitialize="showEvent(event)"
[*]                                   initialize="showEvent(event)"
[*]                                   creationComplete="showEvent(event)"
[*]                                   updateComplete="showEvent(event)"/>
[*]        </mx:Canvas>
[*]        
[*]        <mx:Button id="btn2"
[*]                           preinitialize="showEvent(event)"
[*]                           initialize="showEvent(event)"
[*]                           creationComplete="showEvent(event)"
[*]                           updateComplete="showEvent(event)"/>
[*]        
[*]</mx:Application>
页: [1]
查看完整版本: [转]FLEX的初始化顺序