Programmatically close an AIR application

Phil picture Phil · Feb 17, 2011 · Viewed 8.3k times · Source

I would like to know the correct way to close an AIR application programmatically.

In my Spark WindowedApplication I have:

this.addEventListener( Event.CLOSING, shutdownApp );

and of course an implementation of the shutdownApp method (which basically tidies up temporary files).

This works fine for the top-right close button of the window. However I also have functionality which needs to shutdown the application. Within the code I have called:

NativeApplication.nativeApplication.exit();

However this doesn't trigger the Event.CLOSING method, and so my temporary files are not cleared up. Should I not be calling nativeApplication.exit ? If so, what should I call instead? I'd rather not have to call my shutdownApp method before the NativeApplication.exit() as this doesn't feel quite so elegant.

Can anyone shed any light on the correct way of doing this?

Thanks,

Phil

Answer

Dale Fraser picture Dale Fraser · Dec 1, 2011

I know this question has been answered and accepted, but thought I'd share, I use.

stage.nativeWindow.close();