starling 中的 EventDispatcher 和 Flash中原生的 EventDispatcher
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的更多相关文章
- FLASH CC 2015 CANVAS (二)html中写JS调用flash中的元件、函数、变量
注意 此贴 为个人边“开荒”边写,所以不保证就是最佳做法,也难免有错误! 正式教程会在后续开始更新 当你导出第一个canvas后,你会在保存fla的文件夹里 (每个项目默认位置)看到 如下文件,(请先 ...
- [ActionScript 3.0] flash中的颜色
在 Flash 中,颜色就是一串特殊的数字,一个颜色值可以是0到16,777,215中的任意数值,这就是24位(bit)色彩.也许大家会问,为什么有16,777,216(256*256*256)种颜色 ...
- FLASH CC 2015 CANVAS (三) flash中写JS调用html中JS的函数,变量
注意 此贴 为个人边“开荒”边写,所以不保证就是最佳做法,也难免有错误! 正式教程会在后续开始更新 首先我们在HTML里的JS里面添加几行代码 我们在FLASH中新建一个元件,并拖入到舞台,在属性面板 ...
- ECC校验原理以及在Nand Flash中的应用
本篇文章主要介绍ECC基本原理以及在Nand Flash中的应用,本文记录自己对ECC校验原理的理解和学习. ECC介绍 ECC,全称为Error Correcting Code, ...
- flash中函数的理解
flash 中的函数, 只有在调用时,会分配 数据地址(参数数据,返回数据等)和代码地址. 并运行语句,得到结果(返回数据). 结果(返回数据)赋值后 函数调用结束,释放所有建立的所有空间. ---- ...
- 程序在nor flash中真的可以运行吗?
程序在nor flash中可以运行,但是是有限制的,它不能像RAM那样随意的写(尽管它可以随意的读).在norflash上,不能运行写存储器的指令,不过排除写的地方是RAM类.实验中的三个文件如下所示 ...
- flash 中无法导出swf文件的解决方法
近一个星期,我的flash cs6一直导不出swf文件,郁闷了好长时间,今天终于在网上找到了解决办法:总结了一下,如下: 一.是把文字打散,变成形状. 二.是把汉字的字体设成fla ...
- NAND Flash中常用的纠错方式(ECC算法)
Hanming,RS,BCH —— NAND Flash中常用的纠错方式 因为闪存中会有出错的可能,如果没有使用ECC模块,读出的数据和写入的数据会有不匹配的可能,也许一个文件中只有一两个bit不匹配 ...
- Html在网页、页面中放置Swf、Flash 背景
Html 在网页.页面中放置Swf.Flash背景: <embed src="image/index.swf" wmode=transparent style="p ...
随机推荐
- puppet运维配置实列
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABQkAAAGBCAIAAABKMKAEAAAgAElEQVR4nOydeXwU9cH/t2o9WutR+7
- MSSQL数字时间(timestamp)转换为DATETIME
很简单: , CAST('1970-01-01 00:00:00' AS datetime))
- 原来DataTable的Distinct竟如此简单![转]
本文转自:http://www.cnblogs.com/BlueFly/archive/2009/01/08/1372151.html 有时我们需要从DataTable中抽取Distinct数据,以前 ...
- 问题-delphi 程序在某电脑中显示???问号 乱码
问题现象:delphi 程序在某电脑中显示???问号 乱码 问题原因:因为语言的原因.不同的国家可能显示的编码不一样. 问题处理:“控制面板”>“区域和语言选项”>“区域选项”>“标 ...
- javascript函数的4种调用方式
在javascript中一共有4种函数调用模式,分别是:方法调用模式.函数调用模式.构造函数调用模式和apply(call)调用模式,这4种模式的主要差异在于如何初始化关键参数this. 方法调用模式 ...
- Shell脚本编程的常识
(这些往往是经常用到,但是各种网络上的材料都语焉不详的东西,个人认为比较有用) 七种文件类型 d 目录 ...
- UML 2中结构图的介绍
原文: http://www.ibm.com/developerworks/cn/rational/rationaledge/content/feb05/bell/ 这是关于统一建模语言.即UML 里 ...
- [React] React Fundamentals: Mixins
Mixins will allow you to apply behaviors to multiple React components. Components are the best way t ...
- win10系统调用架构分析
http://blog.csdn.net/liuyez123/article/details/50992038
- 如何在 Objective-C 的环境下实现 defer
关注仓库,及时获得更新:https://github.com/draveness/iOS-Source-Code-Analyze Follow: https://github.com/Dravenes ...
Object