AS3事件加参数以及删除事件

加个引用
类似:

代码
var func:Function;
stage.addEventListener(MouseEvent.CLICK,func
= function(e){a( 1 )});
function a(b) {
        trace(b);
        stage.removeEventListener(MouseEvent.CLICK,func);
}


//或者

代码
stage.addEventListener(MouseEvent.CLICK,function(e:MouseEvent){a(e,arguments.callee, 1 , 2 , 3 )});
function a(e:MouseEvent,caller:Function,arg) {
        trace(arg);
        stage.removeEventListener(MouseEvent.CLICK,caller);
}


获取引用:
arg[0],arg[1],arg[2]

实例:

代码
var easing:Number  =   0.05 ;
txt_mc.addEventListener(Event.ENTER_FRAME,function(e:Event){a(e,arguments.callee,
10 )});


function a(e:Event,caller:Function,arg){
        var a:MovieClip
=  e.target as MovieClip;
        
if (arg[ 0 ] - a.height <- 1 ){
                a.height 
+= (arg[ 0 ] - a.height) * easing;
                trace(a.height);
        }
else {
                trace(
" 结束 " )
                a.height 
= arg[ 0 ];
                a.removeEventListener(Event.ENTER_FRAME,caller);
        }
}

//

var easing:Number 
=   0.1 ;
var fun:Function 
=  function(e:Event){Scrolling(e, 80 );};
txt_mc.addEventListener(Event.ENTER_FRAME,fun);

function Scrolling(e:Event,len:
int ){
        var a:MovieClip
=  e.target as MovieClip;
        
if (len - a.height <- 0.5 ){
                a.height 
+= (len - a.height) * easing;
        }
else {
                trace(
" 结束 " )
                a.height 
= len;
                a.removeEventListener(Event.ENTER_FRAME,fun);
        }
}

 

你可能感兴趣的:(as3)