Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically close an AIR application

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

like image 395
Phil Avatar asked Feb 17 '11 16:02

Phil


2 Answers

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

stage.nativeWindow.close();
like image 85
Dale Fraser Avatar answered Nov 15 '22 07:11

Dale Fraser


The documentation looks a bit ambiguous on this and I would have the same interpretation that you did. Did you try the close or exit methods on the WindowedApplication?

Something like this, with FlexGlobals and topLevelApplication:

(FlexGlobals.topLevelApplication as WindowedApplication).close();

or

(FlexGlobals.topLevelApplication as WindowedApplication).exit();
like image 33
JeffryHouser Avatar answered Nov 15 '22 05:11

JeffryHouser