宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应
您当前的位置: > 博客2 > AS2与AS3技术

addEventListener注册事件进行传递参数的方法(AS3)

2016-10-13 00:16:48 点击量:16 标签: 收藏本文

addEventListener注册事件进行传递参数的方法(AS3):

  1. /**  
  2. * @author:ycccc8202  
  3. * @用途:注册事件进行传递参数的代理类  
  4. * @date:2007.8.26  
  5. * @example:  
  6. * import CYPL.utils.JEventDelegate  
  7.   stage.addEventListener(MouseEvent.MOUSE_DOWN,
  8. JEventDelegate.create(mouseDownHandler,"a","b"));  
  9.   function mouseDownHandler(e:MouseEvent,...arg) {  
  10.   trace(e)  
  11.   trace(arg)  
  12.   }  
  13. */  
  14. package CYPL.utils{  
  15.  import flash.events.Event  
  16.  public class JEventDelegate {   
  17.   public function JEventDelegate() {  
  18.   }  
  19.   public static function create(f:Function,... arg):Function {  
  20.   return function(e:Event){  
  21.   f.apply(null,[e].concat(arg));}   
  22. };  
  23. public static function toString():String {  
  24.  return "Class JEventDelegate";  
  25. }  
  26. }  

 使用格式如下:

  1. import CYPL.utils.JEventDelegate  
  2.   stage.addEventListener(MouseEvent.MOUSE_DOWN,JEventDelegate.create
  3. (mouseDownHandler,"a","b"));  
  4.   function mouseDownHandler(e:MouseEvent,...arg) {  
  5.   trace(e)  
  6.   trace(arg)  
  7.   } 
ABOUT US
宜昌农人网络科技有限公司

我们是一家提供综合软件外包与弱电工程服务的技术公司。

业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。

公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室