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+ "月" );
}
网友评论