我们如何监听父组件内 PopUpWindow 中调度的事件?

发布于 2024-10-08 17:19:00 字数 888 浏览 0 评论 0原文

我有一个警告 Popwindow,有 2 个按钮“提交”和“取消”。 单击提交后,我调用一个函数并调度“submit”事件,气泡为 true。我想在我的父应用程序中处理这个问题。我已经向父容器以及弹出实例注册了该事件。

Inside Parent.mxml :


private function launchWarningPopUp():void {
        var win:Warning = PopUpManager.createPopUp(this, Warning, false ) as Warning; 
        win.addEventListener(SubmitQuizEvent.SUBMIT_QUIZ, submissionDone);
        this.addEventListener(SubmitQuizEvent.SUBMIT_QUIZ, submissionDone);
        PopUpManager.centerPopUp(win);
}

private function submissionDone():void{
   Alert.show('Inside SubmissionDoneTwo');
}

Inside Warning.mxml:

private function submitHanlder():void {
            dispatchEvent(new SubmitQuizEvent(SubmitQuizEvent.SUBMIT_QUIZ,true));
            PopUpManager.removePopUp(this);
}

该事件应该冒泡到 Parent.mxml。 我在这里做错了什么还是根本不可能?

我被困在这里,在这方面的任何帮助将不胜感激。 提前致谢。

I have a warning Popwindow with 2 buttons 'Submit' and 'Cancel'.
On clicking submit I invoke a function and dispatch 'submit' Event with bubble true. I want to handle this inside my parent application. I have already registered the event with the parent container as well as the popup instance.

Inside Parent.mxml :


private function launchWarningPopUp():void {
        var win:Warning = PopUpManager.createPopUp(this, Warning, false ) as Warning; 
        win.addEventListener(SubmitQuizEvent.SUBMIT_QUIZ, submissionDone);
        this.addEventListener(SubmitQuizEvent.SUBMIT_QUIZ, submissionDone);
        PopUpManager.centerPopUp(win);
}

private function submissionDone():void{
   Alert.show('Inside SubmissionDoneTwo');
}

Inside Warning.mxml:

private function submitHanlder():void {
            dispatchEvent(new SubmitQuizEvent(SubmitQuizEvent.SUBMIT_QUIZ,true));
            PopUpManager.removePopUp(this);
}

The event should bubble to Parent.mxml.
Am I doing something wrong here or is it simply not possible ?

I am stuck here, any help in this regard would be greatly appreciated.
Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜灵血窟げ 2024-10-15 17:19:00

您应该将事件侦听器添加到 systemManager,因为弹出窗口是系统管理器的直接子级

You should add your event listener to the systemManager because popups are direct children of the system manager

甜妞爱困 2024-10-15 17:19:00

你是对的。弹出窗口不是创建它的组件的子组件。正如 Florian 所说,它是 systemManager 的子级,并且事件不会像您预期的那样冒泡。

You are correct. the popup is not a child of the component that creates it. It is, as Florian said, a child of systemManager and events don't bubble as you might expect.

彼岸花似海 2024-10-15 17:19:00

由于签名丢失,我无法在函数中捕获此事件。添加此代码后,代码就起作用了。

private function submissionDone(event:SubmitQuizEvent):void{

            Alert.show('Inside SubmissionDone with signature');
}

=================================================== =================================

我现在面临另一个问题。
仅当我使用“win.addEventListener ....”而不是“this.addEventListener ......”时才会捕获该事件。这让我感到惊讶。

如果 Parent.mxml 是“win”的父级,那么“win”内部触发的事件应该冒泡并且应该被父级捕获。这不会发生。

'win' 不被视为 Parent.mxml 的子级吗?并被视为外部组件?

请告诉我您对此的看法?

I was unable to catch this event inside my function as the signature was missing. After I add this the code worked.

private function submissionDone(event:SubmitQuizEvent):void{

            Alert.show('Inside SubmissionDone with signature');
}

=================================================================================

I am facing another issue now.
The event is captured only when I use ' win.addEventListener....' and not with 'this.addEventListener ............'.This is surprizing to me.

If Parent.mxml is parent of 'win' then the events triggered inside 'win' should bubble and should be caught by the parent. This is not happening.

Is 'win' not considered child of the Parent.mxml ? And is treated as external component ?

Please let me know your view on this ??

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文