Flex 事件分发(FlexViewer事件机制)剥离过程(flex.)全程干货

随心笔谈2年前发布 编辑
165 0
🌐 经济型:买域名、轻量云服务器、用途:游戏 网站等 《腾讯云》特点:特价机便宜 适合初学者用 点我优惠购买
🚀 拓展型:买域名、轻量云服务器、用途:游戏 网站等 《阿里云》特点:中档服务器便宜 域名备案事多 点我优惠购买
🛡️ 稳定型:买域名、轻量云服务器、用途:游戏 网站等 《西部数码》 特点:比上两家略贵但是稳定性超好事也少 点我优惠购买


package com
{
import flash.events.Event;

public class AppEvent extends Event
{
//————————————————————————–
//
// Properties
//
//————————————————————————–

private var _data:Object;

private var _callback:Function;

public function AppEvent(type:String, data:Object=null, callback:Function=null)
{
super(type);
_data=data;
_callback=callback;
}

public function get data():Object
{
return _data;
}

public function set data(value:Object):void
{
_data=value;
}

public function get callback():Function
{
return _callback;
}

public function set callback(value:Function):void
{
_callback=value;
}

public override function clone():Event
{
return new AppEvent(this.type, this.data, this.callback);
}

public function dispatch():Boolean
{
return EventBus.instance.dispatchEvent(this);
}

public static function dispatch(type:String, data:Object=null, callback:Function=null):Boolean
{
return EventBus.instance.dispatchEvent(new AppEvent(type, data, callback));
}

public static function addListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void
{
EventBus.instance.addEventListener(type, listener, useCapture, priority, useWeakReference);
}

public static function removeListener(type:String, listener:Function, useCapture:Boolean=false):void
{
EventBus.instance.removeEventListener(type, listener, useCapture);
}

}
}

© 版权声明

相关文章