Properly destroying a flash object in UI dialog on close
We have a flash player that we load up in a modal jquery UI dialog. When I call ('#dialog').dialog('destroy') as part of a close button's functionality (defined through the buttons property, everything is fine. When I instead call the destroy through the beforeclose or close event handler (for when the user hits escape or the X button) I'm getting a Flash J/S (or ActionScript, not sure) error in IE.
I suspect it's due to a race condition between the flash player trying to play while the dialog is being destroyed. There is no error in Firefox. If I set closeOnEscape to false and hide the X button so that the user is forced to click our close button (which calls close and destroy) then everything works fine.
I'm wondering if anyone has run across this and if so how they solved it. I'm happy to leave the X button and escape functionality out - this is more for my own edification.
Thanks,
--adam