当前位置: 代码迷 >> Web前端 >> Application的初始化过程中有四个函数顺序
  详细解决方案

Application的初始化过程中有四个函数顺序

热度:81   发布时间:2012-11-14 10:12:19.0
Application的初始化过程中有4个函数顺序
在Application的初始化过程中有4个函数,一直都对这个顺序比较模糊,最近改了一个代码才搞明白的顺序:

preinitialize

initialize

creationComplete

applicationComplete

测试的代码如下,里面还包括了点击按钮的事件顺序:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
     xmlns:mx="http://www.adobe.com/2006/mxml"
     layout="absolute"
     backgroundGradientColors="[#67cbff, #fcffff]"
     color="#000000"
     fontSize="12"   
     preinitialize="report( event , &apos;preinitialize&apos; )"
     initialize="report( event , &apos;initialize&apos; )"
     creationComplete="report( event , &apos;creationComplete&apos; )"
     applicationComplete="report( event , &apos;applicationComplete&apos; )"
     >
   
     <mx:Script>
         <![CDATA[   
                   
             [Bindable]
           
             public var outTextData:String="";
           
             public function report( event:Event , value:String ):void
             {
                 outTextData += event.type + " " + String(flash.utils.getTimer()) + "\n";   
             }
           
         ]]>
     </mx:Script>
   
      <mx:TextArea
          id="outTextArea"
          text="{ outTextData }"
          right="10" left="10" top="50" bottom="10" alpha="0.5"
          wordWrap="false"
          initialize="report( event , &apos;initialize&apos; )"
          creationComplete="report( event , &apos;creationComplete&apos; )"
          />
    
      <mx:Button
          y="10" height="30" left="168" width="150"
          id="HelloButton"
          label="Say Hello"
          initialize="report( event , &apos;initialize&apos; )"
          creationComplete="report( event , &apos;creationComplete&apos; )"
          rollOver="report( event , &apos;rollOver&apos; )"
          rollOut="report( event , &apos;rollOut&apos; )"
          click="report( event , &apos;click > Hello!&apos; )"
          />
        
      <mx:Button
          id="GoodByeButton"
          label="Say Goodbye"
          y="10" left="10" height="30" width="150" color="#000000"
          initialize="report( event , &apos;initialize&apos; )"
          creationComplete="report( event , &apos;creationComplete&apos; )"
          click="report( event , &apos;click > Goodbye!&apos; )"
          />
        
      <mx:Button
          id="ClearButton"
          label="Clear"
          y="10" left="326" height="30" color="#000000" right="10"       
          initialize="report( event , &apos;initialize&apos; )"
          creationComplete="report( event , &apos;creationComplete&apos; )"
          click="outTextData=&apos;&apos;;report( event , &apos;click&apos; )"
           />
   
</mx:Application>

  相关解决方案