flex 处理事件的侦听器函数 带参数传值

封装类

---------------------------------------------------------------------------------------------------------

 

 

package
{
 public class EventArgExtend
 {
  public function EventArgExtend()
  {
  }
  public static function create(f:Function,... arg):Function
  {
   var F:Boolean=false;
   var _f:Function=function(e:*,..._arg):*
   {
    _arg=arg
    if(!F)
    {
     F=true
     _arg.unshift(e)
    }
    f.apply(null,_arg)
   };
   return _f;
  }
  public static function toString():String
  {
   return "Class JEventDelegate";
  }
 }
 
}

 

 

 

 

 

 

--------------------------------------------------------------------------------------------

 

使用方法

 

_ui.addEventListener(MouseEvent.CLICK,EventArgExtend.create(clickHandler,'id','name'));

 

 

protected function clickHandler(event:MouseEvent,id:String,name:String):void
   {


        _invoke(id,name); 
    
   }

 


    

 

你可能感兴趣的:(Flex)