`
hgfghwq18
  • 浏览: 46079 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
社区版块
存档分类
最新评论

使用as3中EventDispatcher类

阅读更多

用法大同小异
package{
import flash.events.EventDispatcher;
import flash.events.Event;
//继承EventDispatcher类
class CustomDispatcher extends EventDispatcher {
//事件名
  public static var ACTION:String = "action";
//发出事件的方法
public function doAction():void {
dispatchEvent(new Event(CustomDispatcher.ACTION));
}
}
}
在fla中,
import CustomDispatcher
var evtIns=new CustomDispatcher()
//接收事件
evtIns.addEventListener(CustomDispatcher.ACTION,funcHangler)
function funcHangler(evt:Event){
  //输出事件名
  trace(evt.type)
}
//发出事件
evtIns.doAction()
本文转自:http://www.5uflash.com/flashjiaocheng/Flash-as3-jiaocheng/1794.html
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics