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 ...
随机推荐
- Robotium学习笔记一
一. 重签名问题 1.从手机Pull所需的apk通过压缩工具删除META-INF目录 2.通过以下命令行进行签名 >jarsigner -keystore "C:\Documents ...
- CSS3最简洁的轮播图
<!DOCTYPE html> <html> <head> <title>CSS3最简洁的轮播图</title> <style> ...
- 手把手教你入门web.xml:吃透监听器
监听器的原理: 被监听对象→对象拥有的事件→捕获到事件变化→监听器捕捉事件→监听器处理该事件 Web服务器上有4个范围,抛开page范围,还有request范围,session范围,applicati ...
- java request判断微信客户端访问
微信客户端访问时候user-agent信息如下: Mozilla/5.0 (Linux; Android 5.0.1; M040 Build/LRX22C) AppleWebKit/537.36 (K ...
- 遇到Class Not registered的COM异常怎么办
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:遇到Class Not registered的COM异常怎么办.
- windows 文件名太长无法删除的解决方法
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- 获取datagrid中编辑列combobox的value值与text值
var ed = $('#dg').datagrid('getEditor', {index:editIndex,field:'productid'}); var productname = $(ed ...
- HTTP POST发消息
业务需求:模拟TANX给DSP发消息,protobuf数据已弄好. 代码: def PostDataToDSP(self,url,postdata): headers = { #taobao文档规定 ...
- 安装Rational Rose启动报错:无法启动此程序,由于计算机中丢失 suite objects.dll。
执行Rational Rose的时候假设出现这种错误,先检查环境变量有没有common的地址,假设没有直接配上就OK:配置例如以下:D:\Program Files\Rational\Common; ...
- Apache Mina 2.x 框架+源码分析
源码下载 http://www.apache.org/dyn/closer.cgi/mina/mina/2.0.9/apache-mina-2.0.9-src.tar.gz 整体架构 核心过程(IoA ...
Object