EventDispatcher.addEventListener()
期望事件类型的第一个参数(字符串类型的参数)。
但是当前对象可以产生多种类型的事件。
是否可以在一个处理程序中处理所有这些?可能我可以传递null
类型参数或其他东西吗?
EventDispatcher.addEventListener()
期望事件类型的第一个参数(字符串类型的参数)。
但是当前对象可以产生多种类型的事件。
是否可以在一个处理程序中处理所有这些?可能我可以传递null
类型参数或其他东西吗?
Yes, this is possible.
If you use getQualifiedClassName
of the Event class, you could get the types using describeType
. Then you know all types that could be added, assuming you are using a custom event with public static types as strings in same event class. Then you could loop through all types, and add listeners with all those types to the dispatcher.
This idea is included in the templelibrary (EventUtils.addAll
), which I suggest to use.
See documentation: http://templelibrary.googlecode.com/svn/trunk/doc/temple/utils/types/EventUtils.html
您应该尝试让路并扩展 dispatchEvent 功能:
public override function dispatchEvent(evt:Event):Boolean {
trace(evt.type);
return super.dispatchEvent(evt);
}
你可以把你的代码放在这里来处理在这个对象中调度的所有事件。