Reputation: 14197
If this is a duplicate question I am sorry, it seems basic enough but could not find a proper answer.
The only way I have found so far to capture the browser window close event from actionscript/flash is actually to capture the event in javascript, and then use a javascript/flash data passing from the javascript callback.
Something around those lines:
window.onbeforeunload = clean_up;
function clean_up()
{
var flex = document.${application} || window.${application};
flex.myFlexFunction();
}
</SCRIPT>
and the flash part:
import flash.external.ExternalInterface;
ExternalInterface.addCallback("myFlexFunction",cleanUp);
public function cleanUp():void{
//your flash code here
}
Is this the proper way ? Are there other alternatives ?
Upvotes: 2
Views: 873
Reputation: 46037
You can never catch the window close event from pure flash. That said, as far as I know, this is the proper way to handle this.
Upvotes: 3