0
votes

In my Flex (Flash Builder 4) Air application, I have a spark window , and have set the close="" event handler (also tried the 'closing' event) to a method that pops up an alert confirming if they want to close the window.

This worked fine in my normal browser based app as a TitleWindow, but now that it's an Air app with a native spark window, it's not working. I never see the alert dialog, and if I debug trace, it does in fact go in to my close handler method, but visually I can see the window is already gone from the screen.

In an AIR application, how do you add a confirmation dialog for when they click the "x" to close the window?

1
are you using popup manager to create popup window?rejo

1 Answers

1
votes

From the docs it looks like closing would be the one to do it, copied from the docs below:

closing Event
Event Object Type: flash.events.Event property Event.type = flash.events.Event.CLOSING Runtime Versions: AIR 1.0 Dispatched by this NativeWindow object immediately before the window is to be closed. This event can be canceled to prevent the window from being closed.

The Event.CLOSING constant defines the value of the type property of a closing event object. This event has the following properties:

Property Value bubbles false cancelable true; canceling this event object stops the close operation. currentTarget The object that is actively processing the Event object with an event listener. target The object whose connection is to be closed.

Taken from: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/NativeWindow.html#event:closing

It says close does happen after the window is closed but closing should be right before and can be cancelled to stop the window from closing.