starling 比较早之前就有开始解了,但只到最近参与一个用starling 做为框架的手游项目才真正做为一程来使用它。 项目也是刚开始搭建,在这做些笔记。

在写一个管理类时, 遇到 starling.events.EventDispatcher 和 flash.events.EventDispatcher, 这两者有什么区别呢,查了下手册

Package starling.events
Class public class EventDispatcher
Inheritance EventDispatcher Object
Subclasses DelayedCall, DisplayObject, Starling, Tween

The EventDispatcher class is the base class for all classes that dispatch events. This is the Starling version of the Flash class with the same name.

The event mechanism is a key feature of Starling's architecture. Objects can communicate with each other through events. Compared the the Flash event system, Starling's event system was simplified. The main difference is that Starling events have no "Capture" phase. They are simply dispatched at the target and may optionally bubble up. They cannot move in the opposite direction.

As in the conventional Flash classes, display objects inherit from EventDispatcher and can thus dispatch events. Beware, though, that the Starling event classes are not compatible with Flash events: Starling display objects dispatch Starling events, which will bubble along Starling display objects - but they cannot dispatch Flash events or bubble along Flash display objects.

这可以看出, starling中的eventDispatcher 跟原生的是两个完全不同的接口不同的类, 相比较而言,更简洁, 没有原生的捕获阶段,目标阶段,冒泡阶段。 可以自设事件是否需要冒泡,但这是单向不可逆的。

dispatchEventWith(type:String, bubbles:Boolean = false, data:Object = null):void
Dispatches an event with the given parameters to all objects that have registered listeners for the given type.

由于starling 内部的显示对象都是继承 starling.events.EventDispatcher 所以 建议所有渲染相关的事件都用 starling.events

其它自定义的游戏逻辑,建议用原生的 flash.events 便于扩展。

starling 中的 EventDispatcher 和 Flash中原生的 EventDispatcher的更多相关文章

  1. FLASH CC 2015 CANVAS (二)html中写JS调用flash中的元件、函数、变量

    注意 此贴 为个人边“开荒”边写,所以不保证就是最佳做法,也难免有错误! 正式教程会在后续开始更新 当你导出第一个canvas后,你会在保存fla的文件夹里 (每个项目默认位置)看到 如下文件,(请先 ...

  2. [ActionScript 3.0] flash中的颜色

    在 Flash 中,颜色就是一串特殊的数字,一个颜色值可以是0到16,777,215中的任意数值,这就是24位(bit)色彩.也许大家会问,为什么有16,777,216(256*256*256)种颜色 ...

  3. FLASH CC 2015 CANVAS (三) flash中写JS调用html中JS的函数,变量

    注意 此贴 为个人边“开荒”边写,所以不保证就是最佳做法,也难免有错误! 正式教程会在后续开始更新 首先我们在HTML里的JS里面添加几行代码 我们在FLASH中新建一个元件,并拖入到舞台,在属性面板 ...

  4. ECC校验原理以及在Nand Flash中的应用

         本篇文章主要介绍ECC基本原理以及在Nand Flash中的应用,本文记录自己对ECC校验原理的理解和学习. ECC介绍      ECC,全称为Error Correcting Code, ...

  5. flash中函数的理解

    flash 中的函数, 只有在调用时,会分配 数据地址(参数数据,返回数据等)和代码地址. 并运行语句,得到结果(返回数据). 结果(返回数据)赋值后 函数调用结束,释放所有建立的所有空间. ---- ...

  6. 程序在nor flash中真的可以运行吗?

    程序在nor flash中可以运行,但是是有限制的,它不能像RAM那样随意的写(尽管它可以随意的读).在norflash上,不能运行写存储器的指令,不过排除写的地方是RAM类.实验中的三个文件如下所示 ...

  7. flash 中无法导出swf文件的解决方法

    近一个星期,我的flash cs6一直导不出swf文件,郁闷了好长时间,今天终于在网上找到了解决办法:总结了一下,如下:      一.是把文字打散,变成形状.      二.是把汉字的字体设成fla ...

  8. NAND Flash中常用的纠错方式(ECC算法)

    Hanming,RS,BCH —— NAND Flash中常用的纠错方式 因为闪存中会有出错的可能,如果没有使用ECC模块,读出的数据和写入的数据会有不匹配的可能,也许一个文件中只有一两个bit不匹配 ...

  9. Html在网页、页面中放置Swf、Flash 背景

    Html 在网页.页面中放置Swf.Flash背景: <embed src="image/index.swf" wmode=transparent style="p ...

随机推荐

  1. cmd 里面运行git提示“不是内部或外部命令,也不是可运行的程序”的解决办法

    1.找到你电脑上的git安装中bin的路径,如:E:\安装吧\Git\Git\bin:同时,找到git安装路径中git-core的位置,如:E:\安装吧\Git\Git\libexec\git-cor ...

  2. 字符串匹配算法之Rabin-Karp算法

    关键思想在于把输入的字符既看作图形符号,又看做数字,预处理算出模式P的d进制的值p,时间复杂度为Θ(m),让后针对n - m + 1个有效偏移s计算出相应的ts,这里是由于利用ts来计算ts+1,时间 ...

  3. 如何通过进程名获取进程ID

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:如何通过进程名获取进程ID.

  4. html图片滚动效果

    分享一个手动控制图片左右滚动的代码 先说html部分,建立一个层,写出他的样式,层中在建立一个小一点的层用来存放需要滚动的图片,小层两边再建两个小层用来存放控制图片左右滚动的按钮.代码如下: 样式表: ...

  5. JS/JQ综合总结

    总结 js部分 一 语法结构 1 区分大小写 2注意 //单行  /*多行注释*/ 3子面量(直接量 literal) 12//数字 5.8//小数 "hello"字符串 true ...

  6. ubuntu压缩解压

    ubuntu安装解压rar   一般通过默认安装的ubuntu是不能解压rar文件的,只有在安装了rar解压工具之后,才可以解压.其实在ubuntu下安装rar解压工具是非常简单的,只需要两个步骤就可 ...

  7. android 读取用户号码,手机串号,SIM卡序列号

    简介: IMSI:international mobiles subscriber identity国际移动用户号码标识,这个一般大家是不知道,GSM必须写在卡内相关文件中:MSISDN:mobile ...

  8. dubbo资料

    http://blog.csdn.net/morning99/article/details/40426781http://blog.csdn.net/ruishenh/article/details ...

  9. iOS开发多线程篇---atomic nonatomic区别

    摘要 atomic和nonatomic区别用来决定编译器生成的getter和setter是否为原子操 作.atomic提供多线程安全,是描述该变量是否支持多线程的同步访问,如果选择了atomic 那么 ...

  10. Monitoring and Tuning the Linux Networking Stack: Receiving Data

    http://blog.packagecloud.io/eng/2016/06/22/monitoring-tuning-linux-networking-stack-receiving-data/ ...