2010年5月5日 星期三

Lift Cycle , 元件生命週期與應用程式週期


§元件生命週期與應用程式週期
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009
  xmlns:s="library://ns.adobe.com/flex/spark
  xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
  preinitialize="application1_preinitializeHandler(event)"
  initialize="application1_initializeHandler(event)"
  creationComplete="application1_creationCompleteHandler(event)"
  applicationComplete="application1_applicationCompleteHandler(event)"
  >
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.managers.SystemManager;
override protected function createChildren():void
{
 //用來將子物件貼附置容器中
 super.createChildren();
 trace("//---------------------------------------------------");
 trace("//createChildren");
 trace("//---------------------------------------------------");
 trace("");
}

override public function invalidateProperties():void
{
 trace("//---------------------------------------------------");
 trace("//invalidateProperties");
 trace("//---------------------------------------------------");
 trace("");
 super.invalidateProperties();
}
override protected function commitProperties():void
{
 trace("//---------------------------------------------------");
 trace("//commitProperties");
 trace("//---------------------------------------------------");
 trace("");
 super.commitProperties();
}
override public function invalidateSize():void
{
 trace("//---------------------------------------------------");
 trace("//invalidateSize");
 trace("//---------------------------------------------------");
 trace("");
 super.invalidateSize();
}
override protected function measure():void
{
 trace("//---------------------------------------------------");
 trace("//measure");
 trace("//---------------------------------------------------");
 trace("");
 super.measure();
}
override public function invalidateDisplayList():void
{
 trace("//---------------------------------------------------");
 trace("//invalidateDisplayList");
 trace("//---------------------------------------------------");
 trace("");
 super.invalidateDisplayList();
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
 trace("//---------------------------------------------------");
 trace("//updateDisplayList");
 trace("//---------------------------------------------------");
 trace("來源>"+this+",width="+this.width              +",height="+this.height);
 trace("來源>"+this+",width="+this.unscaledWidth+",height="+this.unscaledHeight);
 trace("");
 super.updateDisplayList(unscaledWidth, unscaledHeight);
}
protected function application1_preinitializeHandler(event:FlexEvent):void
{
 trace("//---------------------------------------------------");
 trace("//application1_preinitializeHandler");
 trace("//---------------------------------------------------"); 
 trace("");
}
protected function application1_initializeHandler(event:FlexEvent):void
{
 trace("//---------------------------------------------------");
 trace("//application1_initializeHandler");
 trace("//---------------------------------------------------"); 
 trace("");
}
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
 trace("//---------------------------------------------------");
 trace("//application1_initializeHandler");
 trace("//application1_creationCompleteHandler");
 trace("//---------------------------------------------------"); 
 trace("");
}
protected function application1_applicationCompleteHandler(event:FlexEvent):void
{
 trace("//---------------------------------------------------");
 trace("//application1_initializeHandler");
 trace("//application1_applicationCompleteHandler");
 trace("//---------------------------------------------------");  
 trace("");
 //以下這裡可以了解無效化對應有效化動作
 invalidateProperties();
 //invalidateSize();
 //invalidateDisplayList();
}
]]>
</fx:Script>
</s:Application>

/////輸出結果
//---------------------------------------------------
//invalidateDisplayList
//---------------------------------------------------

//---------------------------------------------------
//invalidateProperties
//---------------------------------------------------

//---------------------------------------------------
//invalidateSize
//---------------------------------------------------

//---------------------------------------------------
//invalidateSize
//---------------------------------------------------
//---------------------------------------------------
//invalidateDisplayList
//---------------------------------------------------

//---------------------------------------------------
//invalidateProperties
//---------------------------------------------------

//---------------------------------------------------
//invalidateSize
//---------------------------------------------------

//---------------------------------------------------
//invalidateDisplayList
//---------------------------------------------------

//---------------------------------------------------
//application1_preinitializeHandler
//---------------------------------------------------

//---------------------------------------------------
//createChildren
//---------------------------------------------------

//---------------------------------------------------
//invalidateProperties
//---------------------------------------------------

//---------------------------------------------------
//invalidateSize
//---------------------------------------------------

//---------------------------------------------------
//invalidateDisplayList
//---------------------------------------------------

//---------------------------------------------------
//application1_initializeHandler
//---------------------------------------------------

//---------------------------------------------------
//commitProperties
//---------------------------------------------------

//---------------------------------------------------
//invalidateProperties
//---------------------------------------------------

//---------------------------------------------------
//invalidateSize
//---------------------------------------------------

//---------------------------------------------------
//invalidateDisplayList
//---------------------------------------------------

//---------------------------------------------------
//invalidateDisplayList
//---------------------------------------------------

//---------------------------------------------------
//invalidateSize
//---------------------------------------------------

//---------------------------------------------------
//invalidateDisplayList
//---------------------------------------------------

//---------------------------------------------------
//measure
//---------------------------------------------------
//---------------------------------------------------
//invalidateDisplayList
//---------------------------------------------------
//---------------------------------------------------
//updateDisplayList
//---------------------------------------------------
來源>left_Cycle,width=1276,height=600
來源>left_Cycle,width=1276,height=600

//---------------------------------------------------
//application1_creationCompleteHandler
//---------------------------------------------------
//---------------------------------------------------
//application1_applicationCompleteHandler
//---------------------------------------------------
//---------------------------------------------------
//invalidateProperties
//---------------------------------------------------
//---------------------------------------------------
//commitProperties
//---------------------------------------------------
//---------------------------------------------------
//invalidateDisplayList
//---------------------------------------------------
//---------------------------------------------------
//updateDisplayList
//---------------------------------------------------
來源>left_Cycle,width=1276,height=600
來源>left_Cycle,width=1276,height=600

沒有留言:

張貼留言