开发者

How can we listen to an event dispatched in PopUpWindow inside the parent component?

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.remove开发者_如何学GoPopUp(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.


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


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.


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 ??

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜