Invisible AIR applications…another implementation method.

So I had it on my TODO list to blog about invisible AIR applications, and then MXNA introduced this recent blog post of Shigeru Nakagaki:

http://shigeru-nakagaki.com/index.cfm/2008/4/7/20080407-How-to-create-air-app-which-does-not-appear-in-taskbar

I guess it’s time for me to stop procrastinating…

The good news for me is that Shigeru came up with a completely different way of tackling the issue than I had used. First, I’d like to thank a couple blog posts that helped me during my task:

So here is what I came up with. Basically the window launches then on applicationComplete it closes. The other things to take into account is preventing default actions on the event and then to make sure the AIR app doesn’t autoExit.

[EDITED: The initial code highlighting wordpress plugin I installed jacked up the code. I changed the pluging and re-added the code. START]
Here’s the code.

ActionScript
< view plain text >
  1. applicationComplete="_onApplicationComplete( event )"&gt;
  2. <!--[CDATA[
  3. private function _onApplicationComplete( p_evt:Event ):void
  4. {
  5. // let's catch close
  6. addEventListener( Event.CLOSING, _onClosing );
  7.  
  8. // close the application window
  9. close();
  10. }
  11.  
  12. private function _onClosing( p_evt:Event ):void
  13. {
  14. // prevent the default action
  15. p_evt.preventDefault();
  16.  
  17. // make sure the application process keeps running after the window is closed
  18. NativeApplication.nativeApplication.autoExit = false;
  19.  
  20. // close the window
  21. stage.nativeWindow.close();
  22.  
  23. trace("I am invisible!");
  24. }
  25. ]]-->

[EDITED: The initial code highlighting wordpress plugin I installed jacked up the code. I changed the pluging and re-added the code. END]

Here’s a link to the app.

http://www.iheartair.com/samples/exampleair/InvisibleApp_1.0.air

Btw, since the app runs invisibly, the only way you’ll have to close it once it’s running is to use an operating system tool such as Task Manager on Windows or kill in the Mac terminal to stop the “InvisibleApp.exe” process on your system…can you say evil? Gwa-ha-ha…