如何将事件从ViewNavigatorApplication分派到另一个View

时间:2012-08-06 12:51:00

标签: flex events mobile

我想从ViewNavigatorApplication发送一个事件,并在另一个视图中捕获它。

var terminateEvent:MyEvent = new Event(MyEvent.COMPLETE);
dispatchEvent(terminateEvent);

我没有成功在另一个视图中捕捉到该事件

this.addEventListenerMyEvent.COMPLETE, terminateExperiment_Handler);

我该怎么做?

1 个答案:

答案 0 :(得分:0)

事件只应用于通信显示层次结构;没下来。

如果要进行通信,则应通过更改视图类的属性或调用方法来实现。

也就是说,您可以使用FlexGlobals

在视图中添加应用程序
(FlexGlobals.topLevelApplication as ViewNavigatorApplication).addEventListenerMyEvent.COMPLETE, terminateExperiment_Handler);

以这种方式倾听'父母'通常被认为是封装中的漏洞,我不会轻易推荐这种方法。

相关问题