Reputation: 104
I have a Flash game which send and receive lot of messages from JavaScript. Sometimes I need to stop listening some of those functions, but ExternalInterface doesn't have a removeCallback function. So I'm doing somthing ugly: using a boolean to validate if a callback is available in each function.
Any better solution?
ExternalInterface.addCallback("callAlert", callAlert);
function callAlert(msg:String){
if(callAlertAvailable){
//...
}
}
Upvotes: 2
Views: 1492
Reputation: 5204
Just call again addCallback, setting the function as null:
ExternalInterface.addCallback("callAlert", null);
Why not read the docs? I found it here:
ExternalInterface.addCallback()
Note: Repeating addCallback() on an existing callback function with a null closure value removes the callback.
Upvotes: 4