美文网首页
egret_事件监测

egret_事件监测

作者: iOS小开发 | 来源:发表于2021-12-29 10:11 被阅读0次

class DateEvent extends egret.Event {

public static DATE:string = "date";

public _y :number = 2022;

public _m :number = 12 ;

public constructor(type:string,bubbles:boolean =false, cancelable:boolean =false){

    super(type,bubbles,cancelable);

}

}

class teacher extends egret.DisplayObjectContainer {

public event(){

const event = new DateEvent(DateEvent.DATE);

event._m = 111111;

event._y = 222222;

this.dispatchEvent(event);

    }

}

var te = new teacher();

te.addEventListener(DateEvent.DATE,this. getDate,this);

te.event();

te.removeEventListener(DateEvent.DATE,this.getDate,this);

public getDate(evt:DateEvent){

    console.log("会在" + evt._y + "年" + evt._m+ "月"  );

}

相关文章

网友评论

      本文标题:egret_事件监测

      本文链接:https://www.haomeiwen.com/subject/ioupqrtx.html