To pass a parameter to event listener in AS3 the simple way… does it exist?

前端 未结 5 1801
轻奢々
轻奢々 2020-11-28 04:00

Expected / pseudo example:

stage.addEventListener(MouseEvent.CLICK, onClick.someWayToPassParameters(true, 123, 4.56, "string"));
function onClick(e:         


        
5条回答
  •  半阙折子戏
    2020-11-28 04:36

    here is an example

    var s1:Boolean = true;
    
    station1.addEventListener(MouseEvent.ROLL_OVER, function(e:MouseEvent) : void { spread(e, s1) });
    station1.addEventListener(MouseEvent.ROLL_OUT, function(e:MouseEvent) : void { collapse(e, s1) });
    
    
    function spread(event:MouseEvent ,bb:Boolean):void {
     if(bb != true) event.currentTarget.gotoAndPlay(2);
    }
    
    function collapse(event:MouseEvent,bb:Boolean ):void {
        if(bb != true) event.currentTarget.gotoAndPlay(18);
    }
    

提交回复
热议问题