var _container:Sprite = new Sprite();

 _container.addEventListener(Event.ADDED,onAdded);
_container.addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
_container.addEventListener(Event.REMOVED,onRemoved);
_container.addEventListener(Event.REMOVED_FROM_STAGE,onRemovedFromStage); function onAdded(e:Event):void {
trace("onAdded:",e);
} function onAddedToStage(e:Event):void {
trace("onAddedToStage:",e);
} function onRemoved(e:Event):void {
trace("onRemoved:",e);
} function onRemovedFromStage(e:Event):void {
trace("onRemovedFromStage:",e);
} addChild(_container);
//onAdded: [Event type="added" bubbles=true cancelable=false eventPhase=2]
//onAddedToStage: [Event type="addedToStage" bubbles=false cancelable=false eventPhase=2] var _sub:Sprite = new Sprite(); _container.addChild(_sub);
//onAdded: [Event type="added" bubbles=true cancelable=false eventPhase=3] /*_container.removeChild(_sub);
//onRemoved: [Event type="removed" bubbles=true cancelable=false eventPhase=3]*/ removeChild(_container);
//onRemoved: [Event type="removed" bubbles=true cancelable=false eventPhase=2]
//onRemovedFromStage: [Event type="removedFromStage" bubbles=false cancelable=false eventPhase=2] _container.removeChild(_sub);
//onRemoved: [Event type="removed" bubbles=true cancelable=false eventPhase=3]

区别:

ADDED是子对象被添加到自身时触发,ADDED_TO_STAGE是对象本身被添加到显示列表时触发;类似的:REMOVED当子对象从自身移除时触发,REMOVED_FROM_STAGE是自身从显示列表中移除时触发;

ADDED/REMOVED事件会冒泡,而ADDED_TO_STAGE/REMOVED_FROM_STAGE不冒泡,也就是说每次addChild或removeChild自身时,下面的ADDED/REMOVED事件也会冒泡上来先被触发,然后才触发ADDED_TO_STAGE/REMOVED_FROM_STAGE事件.

原作者:菩提树下的杨过
出处:http://yjmyzz.cnblogs.com

ADDED、ADDED_TO_STAGE、REMOVED、REMOVED_FROM_STAGE这几个事件的区别的更多相关文章

  1. eclipse服务器add and remove 工程时出现there are no resources that can be added or removed from the server

    网上的解决方法: 解决方法: 第1步.新建一个“Dynamic Web Project” 第2步.把新建项目里面的.project文件和.settings文件夹复制到导入的那个项目里面. 可是我发现: ...

  2. eclise 部署web工程报 There are no resources that can be added or removed from the server.

    该文章转自: http://blog.csdn.net/dw_java08/article/details/7789601 eclise 部署web工程报 There are no resources ...

  3. Decoder is not a @Sharable handler, so can't be added or removed multiple times

    Decoder is not a @Sharable handler, so can't be added or removed multiple times final MyMessageDecod ...

  4. eclipse导入git项目出现There are no resources that can be added or removed from the server错误

    上传到git上的项目因为配置了过滤文件,将.settings文件和.project文件都过滤掉了,settings文件中主要存放的是各种插件配置,约束你可以更好的利用IDE进行编码 因为将这两个文件过 ...

  5. 解决 There are no resources that can be added or removed from the server

    网上下载了一个项目,在eclipse中部署时,加载项目到tomcat中项目名称无法显示,报出There are no resources that can be added or removed fr ...

  6. jquery的bind跟on绑定事件的区别

    jquery的bind跟on绑定事件的区别:主要是事件冒泡: jquery文档中bind和on函数绑定事件的用法: .bind(events [,eventData], handler) .on(ev ...

  7. c#之委托和事件的区别

    1.什么是委托,这里就不做介绍了,如果想了解可以查看博客:http://www.cnblogs.com/xiaoxiaogogo/p/3571494.html 下面开始对事件进行介绍 1.定义事件以及 ...

  8. C#中委托和事件的区别实例解析

    这篇文章主要介绍了C#中委托和事件的区别,并分别以实例形式展示了通过委托执行方法与通过事件执行方法,以及相关的执行流程与原理分析,需要的朋友可以参考下 本文实例分析了C#中委托和事件的区别,分享给大家 ...

  9. 转载:STM32之中断与事件---中断与事件的区别

    这张图是一条外部中断线或外部事件线的示意图,图中信号线上划有一条斜线,旁边标志19字样的注释,表示这样的线路共有19套.图中的蓝色虚线箭头,标出了外部中断信号的传输路径,首先外部信号从编号1的芯片管脚 ...

随机推荐

  1. linux使用shell脚本停止java进程

    使用shell脚本停止java进程,过程就是先查出对应的java进程pid,然后kill掉 - | 其中xxx是对应进程的关键词(即从查出的所有java进程中分辨出目标进程)

  2. Nginx的编译安装及选项

    编译安装Nginx1.安装常见的工具和库(GCC.PCRE.zlib.OpenSSL) Nginx是一个由C语言编写的,所以需要一个编译工具如GNU的GCC[root@www ~]# yum inst ...

  3. Ubuntu16.04修改IP及时生效

    1.Network Connetions 窗口管理器中修改IP 2.ifconfig查看网卡名字 3.刷新IP sudo ip addr flush enp2s0 4.sudo service net ...

  4. JID介绍

    JID: 一个XMPP实体的地址称为Jabber Identifier或JID,作用类似于IP地址.一个合法的JID包括节点名,域名资源名,其格式为:jid=[node'@']domain['/'re ...

  5. MySQL binlog_format中sbr 和rbr(Statement-Based and Row-Based Replication)的优缺点

    Advantages of statement-based replication 1 技术成熟 2 对于大量的更新删除等操作,仅仅会写入少量的变更结果,加速日志获取或者备份的速度 3 日志文件包含了 ...

  6. selenium测瀑布流UI页面的Python代码

    from  selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdri ...

  7. [java,2017-05-17] 数据型参数趣谈

    int的最大值是多少?加一呢?乘2呢? 第一个问题我想大多数人都知道,不知道后两个有多少人研究过. 首先上一段代码: public class DecimalTest { public static ...

  8. centos7 lnmp环境部署

    搭建版本 版本组合 php5.6+apache/2.4.6(centos7)+mysql5.7.24 因为新系统不能确认哪些指令已经搭建  所以安装前需要确认下是否拥有 检测是否已经安装过Vim rp ...

  9. python-day19 Django模板,路由分发,ORM

    @获取文件所有数据 request.FILES: request.POST.get('fafafa')#拿到文件名: user = request.POST.get('user',None)#用get ...

  10. Navicat 连接MariaDB 失败: Host '*' is not allowed to connect to this MariaDB server

    题描述:Navicat 为管理方便,连接Linux 中Mariadb失败,如下如下错误:Host '*' is not allowed to connect to this MariaDB serve ...