我目前正在制作一个只传递一个数据的基本自定义事件类。
package {
import flash.events.Event;
public class DateEvent extends Event {
public static const DATE_SET: String = "exampleEvent";
public var calendarObj: Object;
public function DateEvent(type: String, calendarObj: Object = null) {
this.calendarObj = calendarObj;
super(type, false, false);
}
override public function clone(): Event {
return new DateEvent(type, calendarObj);
}
}}
当这样调用事件时:
selectedDate = new Date(displayedYear, displayedMonthNum, displayedDate, displayedHour, displayedMins);
trace(selectedDate);
dispatchEvent(DateEvent(DateEvent.DATE_SET, selectedDate));
我得到一个"不正确数量的参数"错误。我很困惑,因为我没有超过我应该(我认为)的范围。
答案 0 :(得分:0)
在调用new
构造函数之前,您错过了DateEvent
关键字。像这样 -
dispatchEvent(new DateEvent(DateEvent.DATE_SET, selectedDate));