开发者

How to add Mate Listeners using Action Script

开发者 https://www.devze.com 2023-01-26 04:59 出处:网络
in one of my forms, I have used the following code for adding Mate Listeners <mate:Listener type=\"{DBEvent.Update_Result}\" receive=\"{onUpdateResults(event)}\"/>

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 thi开发者_StackOverflow中文版s issue.


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);
0

精彩评论

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