Tombstoning in AIR-Mobile Applications

When you are building AIR-based mobile applications, you can handle Tombstoning in your application in a very elegant way. Tombstoning is a technique by which you freeze the state of your application whenever a system interrupt occurs.  For instance, when the user receives a cellular call, your application will become invisible and may get deactivated or pushed to the background. During that time, there is no point in running those game timers or animations. You can suspend all CPU/GPU intensive activities and resume all of them when the application gets activated again.

Tombstoning is an absolutely required feature that your application should support to provide a less frustrating experience to the users.

In AIR-based mobile applications, handling Tombstoning is absolutely simple.

When you are creating the mobile view, just remember to handle the view-activate and view-deactivate events:

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx=""

            protected function handleDeactivate():void
                   //Pause game timers
                   //Suspend animations

            protected function handleActivate():void
                   //Restart game timers
                   //Resume animations


You can also use these techniques to gracefully shutdown your application as the deactivate event is called on the View when the user taps the back key. Note: Tombstoning will not work if you are building AIR applications with 2.5 or lower namespace.

9 Responses to Tombstoning in AIR-Mobile Applications

  1. Adam Zucchi says:


    Thanks for the article. I typically do not work inside of Flash Builder, so would this tombstoning approach when working in AIR publishing from Flash CS5 be using the NativeApplication class and listening for the EXITING event?

    Thanks again.


    • fjenning says:

      Hey Adam,

      You can try this:

      NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, onNativeAppDeactivated);

      Thus, you can handle the deactivate event.

  2. Pingback: Design Considerations for Building Mobile Applications « Filthy Rich Applications

  3. How would you go about this in a pure AS3 approach for Android? Event.ACTIVATE and Event.DEACTIVATE? And do you set them to stage or to NativeApplication.nativeApplication?

    Kind regards,

    Sidney de Koning

  4. fjenning says:

    For pure AS3, you can use:

    NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, onNativeAppActivated);


    NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, onNativeAppDeactivated);

    Now, on Android with AIR 2.5, this won’t work when your application is pushed to the background due to system interrupts. With AIR 2.6, it will work fine.

  5. So that would work if you get a call for instance?

  6. And why do they get called 4 time in a row? And yes i have only one listener in my entire project.


    • fjenning says:

      Sydney, Do you mean that the DEACTIVATE/ACTIVATE method is called several times when the application gets pushed to the background on Android? If you can share your code, mail your app to fjenning [AT] adobe [DOT] com


  7. Pingback: To Kill or Pause an iOS App (when it’s Deactivated) | roguish