主页 > 知识库 > Flex 事件分发(FlexViewer事件机制)剥离过程

Flex 事件分发(FlexViewer事件机制)剥离过程

热门标签:广州ai外呼系统业务 车载电话机器人 什么行业需要电话机器人 天津企业外呼系统代理商 无锡电销外呼系统代理 中山外呼系统中间件 外呼系统号码显示 南昌crm外呼系统如何 地图标注多家店

将FlexViewer里面的事件分发及监听事件机制剥离出来在其他项目中使用

AppEvent.as

package com 
{ 
import flash.events.Event; 

/** 
* @author SamSung 
* 创建时间:2014-7-24 下午1:21:05 
* 
*/ 
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; 
} 


/** 
* The data will be passed via the event. It allows the event dispatcher to publish 
* data to event listener(s). 
*/ 
public function get data():Object 
{ 
return _data; 
} 

/** 
* @private 
*/ 
public function set data(value:Object):void 
{ 
_data = value; 
} 

/** 
* The callback function associated with this event. 
*/ 
public function get callback():Function 
{ 
return _callback; 
} 

/** 
* @private 
*/ 
public function set callback(value:Function):void 
{ 
_callback = value; 
} 

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

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

/** 
* Dispatch an AppEvent for specified type and with optional data and callback reference. 
*/ 
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); 
} 

} 
}

EventBus.as

package com 
{ 
import flash.events.Event; 
import flash.events.EventDispatcher; 

/** 
* The EventBus allows centrallized communication among modules without 
* point-to-point messaging. It uses the singleton design pattern 
* to make sure one event bus is available globally. The bus itself 
* is only available to the container. Modules use the container's 
* static method to communicate with the event bus. 
*/ 
public class EventBus extends EventDispatcher 
{ 
/** Application event bus instance */ 
public static const instance:EventBus = new EventBus(); 

/** 
* Normally the EventBus is not instantiated via the b>new/b> method directly. 
* The constructor helps enforce only one EvenBus availiable for the application 
* (singeton) so that it asures the communication only via a sigle event bus. 
*/ 
public function EventBus() 
{ 
} 

/** 
* The factory method is used to create a instance of the EventBus. It returns 
* the only instanace of EventBus and makes sure no another instance is created. 
*/ 
[Deprecated(replacement="instance")] 
public static function getInstance():EventBus 
{ 
return instance; 
} 

/** 
* Basic dispatch function, dispatches simple named events. In the case 
* that the event is only significant by the event token (type string), 
* this new dispatch method simplify the code. 
*/ 
[Deprecated(replacement="AppEvent.dispatch")] 
public function dispatch(type:String):Boolean 
{ 
return dispatchEvent(new Event(type)); 
} 
} 
}
您可能感兴趣的文章:
  • 详解Android事件的分发、拦截和执行
  • Android View 事件分发机制详解
  • Android 事件分发详解及示例代码
  • Android事件的分发机制详解
  • Android Touch事件分发深入了解
  • 30分钟搞清楚Android Touch事件分发机制
  • Android Touch事件分发过程详解
  • java随机事件分发器示例
  • Android View事件分发机制详解

标签:吕梁 仙桃 海西 钦州 沧州 佛山 泰州 攀枝花

巨人网络通讯声明:本文标题《Flex 事件分发(FlexViewer事件机制)剥离过程》,本文关键词  Flex,事件,分发,FlexViewer,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《Flex 事件分发(FlexViewer事件机制)剥离过程》相关的同类信息!
  • 本页收集关于Flex 事件分发(FlexViewer事件机制)剥离过程的相关信息资讯供网民参考!
  • 推荐文章