zoukankan      html  css  js  c++  java
  • 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);
            }
    }
  • 相关阅读:
    mybatis遍历map
    程序员开发思考-1
    linux shell学习-1
    IDEA tomcat部署
    理解TCP/IP协议
    winform实现自定义折叠面板控件
    目录特殊符号导致的应用程序处于中断模式
    Vue-element-admin实现菜单根据用户权限动态加载
    基于EF的一个简单实战型分层架构
    Linux开启SELinux的情况下怎么解决nginx403跟502错误
  • 原文地址:https://www.cnblogs.com/sevenyuan/p/1614649.html
Copyright © 2011-2022 走看看