0
votes

The architecture is based on the use of the following frameworks: Flex, Cairngorm and Parsley.

I use a dispatcher with an event "AdicionarItemVendaMercadoriaEvent" within a popuppanel: PopupPanel.

I capture the event with [MessageHandler] within the FormPM.as injected into Form.mxml. Within Form.mxml, I have a mx: TabNavigator and each tab is within one s: NavigatorContent.

It turns out that when there is more than one open tab mx: TabNavigator the dispatched event is captured in all Form of all tabs.

Normal operation was to capture the only event of the tab where the PopupPanel was dispatched, not all tabs.

Please, any suggestions for solving this problem?

I appreciate the help.

1
You could save the tab reference in the message and check it in the handler. - dvdgsng
Yes do the above. Another slightly more optimal approach would be to use a different event type (ie: use AdicionarItemVendaMercadoriaEvent.TAB_ONE, AdicionarItemVendaMercadoriaEvent.TAB_TWO, etc.) for each tab. This way, when you dispatch the message, only one [MessageHandler] would get invoked, instead of invoking them all. - Sunil D.
The tabs are generated dynamically when the User clicks a button to add. Thus, it would be ideal to generate an event differently for each flap. @dvdgsng - user2478505
The tabs are generated dynamically when the User clicks a button to add. Thus, it would be ideal to generate an event differently for each flap. @SunilD. - user2478505

1 Answers

0
votes

How about using straight forward function callbacks?

When you create your PopUpPanel, pass in a function callback that you want to be executed when the popup is closed. Rather than using an event, you'd simply call the function. i.e.

Inside FormPM:

public function showPopup():void
{
    var popup:PopUpPanel = new PopUpPanel();
    popup.onCompletion = handleResult;
    PopUpManager.addPopUp(popup, ...);
}

private function handleResult(someData:*):void 
{
   // My popup has completed.. what do I want to do with the result.
}

You might want to consider the Spicelib 3.0 command framework and have a command to popup your panel and then add the error/success callbacks to that: http://www.spicefactory.org/parsley/docs/3.0/manual/?page=commands&section=intro