当前位置: 首页 > news >正文

UIComponent的生命周期(life cycle)

写flex组件,了解UIComponent的生命周期(life cycle)很重要,尤其是初始化(initialization)的过程很复杂,贴个文件可以很容易看清这个顺序

文件如下:

package
{
import flash.events.Event;

import mx.core.UIComponent;
import mx.events.FlexEvent;

public class UILifeCycle extends UIComponent
{
public function UILifeCycle()
{
super();
trace("***[ constructor ]");

//flash.events.Event
this.addEventListener(Event.ADDED,onAdded);
this.addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
this.addEventListener(Event.REMOVED,onRemoved);
this.addEventListener(Event.REMOVED_FROM_STAGE,onRemovedFromStage);

//mx.events.FlexEvent;
this.addEventListener(FlexEvent.ADD,onAdd);
this.addEventListener(FlexEvent.REMOVE,onRemove);
this.addEventListener(FlexEvent.PREINITIALIZE,onPreinitialize);
this.addEventListener(FlexEvent.INITIALIZE,onInitialize);
this.addEventListener(FlexEvent.CREATION_COMPLETE,onCreationComplete);

}

//flash.events.Event
private function onAdded(eo:Event):void{trace(eo.toString())};
private function onAddedToStage(eo:Event):void{trace(eo.toString())};
private function onRemoved(eo:Event):void {trace(eo.toString())};
private function onRemovedFromStage(eo:Event):void {trace(eo.toString())};

//mx.events.FlexEvent;
private function onAdd(eo:FlexEvent):void {trace(eo.toString())};
private function onRemove(eo:FlexEvent):void{trace(eo.toString())};
private function onPreinitialize(eo:FlexEvent):void{trace(eo.toString())};
private function onInitialize(eo:FlexEvent):void{trace(eo.toString())};
private function onCreationComplete(eo:FlexEvent):void{trace(eo.toString())};

override protected function createChildren():void{trace("***[ createChildren ]")}
override protected function commitProperties():void{trace("***[ commitProperties ]")}
override protected function measure():void{trace("***[ measure ]")}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{trace("***[ updateDisplayList]")}

}
}

拖到舞台上发布就可以看到trace信息了

***[ constructor ]
[Event type="added" bubbles=true cancelable=false eventPhase=2]
[Event type="add" bubbles=false cancelable=false eventPhase=2]
[Event type="preinitialize" bubbles=false cancelable=false eventPhase=2]
***[ createChildren ]
[Event type="initialize" bubbles=false cancelable=false eventPhase=2]
***[ commitProperties ]
***[ measure ]
***[ updateDisplayList]
[Event type="creationComplete" bubbles=false cancelable=false eventPhase=2]
[Event type="addedToStage" bubbles=false cancelable=false eventPhase=2]
http://www.xdnf.cn/news/806833.html

相关文章:

  • 奇迹按键精灵挂机脚本_按键精灵做连击脚本(奇迹MU战士用)
  • Struts2快速入门,超简单详细的快速入门教程
  • 台式计算机cpu允许温度,台式机cpu温度多少正常 台式电脑工作时温度范围
  • 推荐几个比较有助于android深入学习的网址
  • MySQL中文失败问题
  • 世界顶级杀毒软件排名:十二款世界顶级杀毒软件下载!
  • Red5 流媒体 学习(三)
  • Cocos2d-x之Touch事件处理机制
  • 全国各大学精品课程网站
  • 中秋祝福邮件模板来咯!自取不谢!
  • 科普:黑客盗QQ究竟是怎么回事?
  • 16个值得个人站长做的广告联盟[转自cnzz]
  • 市场复盘总结 20240321
  • 如何开启WinXP的IIS服务把z-blog安装到本地
  • 7000万个腾讯QQ群数据遭泄露
  • 如何架设NOD32升级服务器
  • 永恒之蓝漏洞原理
  • TOP Server教程:定义TOP Server管理员密码
  • 支付系统高可用架构设计实战,可用性高达99.999!
  • 如何用C#语言构造蜘蛛程序
  • XDelBox 1.5 公测版发布
  • 【CSS】CSS 文本样式 ② ( font 字体设置 | CSS 2.0手册使用 | font-weight 字体粗细设置 | font-style 字体斜体设置 | font 字体样式综合写法 )
  • 美国php空间推荐,美国php空间php空间推荐
  • hd2刷机详细步骤
  • Linux操作系统简介:为何成为全球开发者热门选择?
  • 收集struts2各种版本下载地址
  • 移动硬盘插服务器上坏了,移动硬盘接口坏了怎么办解决教程
  • 2017全国计算机ps版本,Adobe Photoshop v18.0.0 (PS CC 2017) 中文多语言版本 不断更新
  • 游戏开发之UDK引擎介绍和模型导入
  • android 百度浏览器内核,百度浏览器安卓6.2版上线:新一代内核更快更稳定