starling 中的 EventDispatcher 和 Flash中原生的 EventDispatcher
starling 比较早之前就有开始解了,但只到最近参与一个用starling 做为框架的手游项目才真正做为一程来使用它。 项目也是刚开始搭建,在这做些笔记。
在写一个管理类时, 遇到 starling.events.EventDispatcher 和 flash.events.EventDispatcher, 这两者有什么区别呢,查了下手册
Package | starling.events |
Class | public class EventDispatcher |
Inheritance | EventDispatcher ![]() |
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 ...
随机推荐
- KMP学习总结
初学,理解可能不是那么准确~~ Next数组的含义:next[i]表示第0个元素到第i个元素组成的字符串的最大前缀后缀.Next[0]=0显然. 所以KMP的原理就是 通过找出每一阶段最大的相等的前缀 ...
- 用lambda构建ORM查询语句
本文介绍如何解析lambda表达式来获取一个满足条件的查询语句. 先看个截图 通过设置实体对象Article_Content的查询表达式,就可以获取对应的参数化SQL语句,使用起来很方便,减少了代码 ...
- 用普通PC主板的蜂鸣器给树莓派(RPI)加个报警器
这两天有点时间,捣鼓了下那闲置好久的树莓派,把普通PC主板的蜂鸣器作为树莓派的报警器用. Raspberry Pi有许多的GPIO(General Purpose Input Output:通用输入/ ...
- POJ 1330 Nearest Common Ancestors(Tree)
题目:Nearest Common Ancestors 根据输入建立树,然后求2个结点的最近共同祖先. 注意几点: (1)记录每个结点的父亲,比较层级时要用: (2)记录层级: (3)记录每个结点的孩 ...
- UVA 110 Meta-Loopless Sorts(输出挺麻烦的。。。)
Meta-Loopless Sorts Background Sorting holds an important place in computer science. Analyzing and ...
- Delphi 根据快捷方式路径取源文件地址
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, ...
- ThinkPad New X1 Carbon中关闭任务栏上的触摸键盘
1. 执行services.msc 2. 选择Touch Keyboard and Handwriting Panel 服务. 3. 将其停止执行. 并disable.
- android99 拍照摄像
package com.itheima.camera; import java.io.File; import android.net.Uri; import android.os.Bundle; i ...
- vim的一些高级配置
今天有幸看到一篇博文,有一些vim的高级配置 在linux或者unix下面的.vimrc文件中,在其中可以添加如下片段,可以实现解释上面你说的那些高级用法 " Ctrl + K 插入模式下光 ...
- linux使用过程中遇到的问题和解决方法
测试过程中,出现以下错误,导致远程ssh连接不上,最终导致测试结果失败.系统日志如下: Sep 1 03:15:03 node3 avahi-daemon[5834]: Invalid respo ...