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);
            }
    }
  • 相关阅读:
    CentOS Linux使用crontab运行定时任务详解
    pycharm自定义代码片段
    迭代器:斐波那契数列
    mysql复习-来源考试
    复杂和遗留的数据库schema
    ubuntu系统AndroidStudio修改内存大小
    Hibernate设置时间戳的默认值和更新时间的自动更新
    Android 自定义view --圆形百分比(进度条)
    MYSQL 更新时间自动同步与创建时间默认值共存问题
    ubuntu virtualbox xp无声音解决
  • 原文地址:https://www.cnblogs.com/sevenyuan/p/1614649.html
Copyright © 2011-2022 走看看