0

in one of my forms, I have used the following code for adding Mate Listeners

<mate:Listener type="{DBEvent.Update_Result}" receive="{onUpdateResults(event)}"/>

I am displaying this form as a popup. What happening is, for the first time, onUpdateResults method executed only once as expected. Then i close the popup and reopened it. This time onUpdateResults method called twice, then next 4time and so on...

After so much of googling, i found that Mate Listeners are still active, even though we remove/close the popup. I tried weak references, close the popup using PopupManager.RemovePopup and so on. Nothing worked.

Then i thought of registering and unregistering the mate listeners manually using action script. So, i have tried the following code

var _listener:Listener= new Listener();

_listener.addEventListener(DBEvent.Update_Result,onUpdateResults);

to unregister...

_listener.removeEventListener(DBEvent.Update_Result,onUpdateResults);

But this is also not working.

Please somebody help me fix this issue.

JeffryHouser
  • 39,401
  • 4
  • 38
  • 59
Dinesh
  • 2,026
  • 7
  • 38
  • 60

1 Answers1

0

Try this.

Create runtime popup windows in main application:

PopUpManager.createPopUp(this, MyPopUp, true);

MyPopUp - mx:TitleWindow from MyPopUp.mxml Add any listeners in OnInit in MyPopUp.mxml:

_listener.addEventListener(DBEvent.Update_Result, onUpdateResults);

Close popup when you click any button (button's click event or any):

PopUpManager.removePopUp(this);
Lex
  • 1,378
  • 11
  • 10