0

How to catch up a situation when FLASH is forced to close e.g. because of BACK button click, I need to make one HTTP call before that.

my code:

 stage.addEventListener(Event.CLOSE,unloadEvents,false,0,true);

I can see that FocusEvent.FOCUS_OUT event occurs in that case, but CLOSE or UNLOAD focuses are not appearing?

Tom
  • 6,725
  • 24
  • 95
  • 159

1 Answers1

1

You need javascript to protect from leaving the current page where your flash is located. If user really wants to leave the page then make your http call, else just stay inside the page.

Here are some links... that should help:

How to logout during onbeforeunload/onunload using Javascript

To execute Flex cleanup function when browser is closed by user

Community
  • 1
  • 1
Adrian Pirvulescu
  • 4,308
  • 3
  • 30
  • 47
  • I dont want to protect from leaving, just need to receive event that flash is being closed now so I can save data.. – Tom Mar 04 '14 at 11:17
  • I am afraid this is not possible... else Javascript would be useless in my sample links. You are not the only one facing this... – Adrian Pirvulescu Mar 04 '14 at 14:46
  • thanks for links, window.onbeforeunload seem to work with IE; but not with firefox. I have my SWF file loaded with nested object + embed tags. – Tom Mar 06 '14 at 08:06
  • it may be that in NON-IE browsers the event to be called beforeunload and not with the 'on' in the front. – Adrian Pirvulescu Mar 06 '14 at 08:14
  • Thanks, it made a call but now firefox/chrome gives this error during my http call from flash during this "shutting down" event; Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: – Tom Mar 06 '14 at 13:51