【发布时间】:2011-03-29 22:48:00
【问题描述】:
我在一个 flex 组件中有代码,我想监听一个事件,事件的源是一个自定义类,它由另一个类运行的另一个类运行,等等。我的印象是事件会在整个应用程序中传递,所以我希望我能像这样在类中调度自定义事件..
private function finishEvent():void {
var evt:EventDispatcher = new EventDispatcher;
var finished:Event = new Event("finishedInterpret");
evt.dispatchEvent(finished);
}
然后我可以像这样在我的组件中抓取它:
public function interpret(data:Array):void {
addEventListener("finishedInterpret", applyInferences);
db.executeBatch();
}
该事件基本上是在 executeBatch 完成时触发的,并且正在调用 finishEvent,但我是侦听器没有得到任何东西。我尝试将其设置为 db.addEventListener,但现在生效了。
【问题讨论】:
标签: actionscript-3 event-handling addeventlistener dispatchevent