egret_事件监测

2021-12-29  本文已影响0人  iOS小开发

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+ "月"  );

}

上一篇下一篇

猜你喜欢

热点阅读