     
     /**
      *  @private
+     */
+    private function nativeApplication_deactivateHandler(event:Event):void
+    {
+        // Close the softKeyboard if we deactivate the application. This works
+        // around an iOS bug where the SoftKeyboard.DEACTIVATE event isn't
+        // dispatched when the application is deactivated. 
+        if (isSoftKeyboardActive)
+        {
+            stage.focus = null;
+            softKeyboardDeactivateHandler(null);
+        }
+    }
+    
+    /**
+     *  @private
      *  Called when a softKeyboard activation target is removed from the
      *  stage.  If the target has stage focus, then the focus is set to null.
      *  This will cause a SOFT_KEYBOARD_DEACTIVATE event to be dispatched.

            addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE, 
                softKeyboardDeactivateHandler, true, 
                EventPriority.DEFAULT, true);
        }
    }

    /**
     *  @private
     */

import flash.display.Stage;
import flash.events.ContextMenuEvent;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.SoftKeyboardEvent;
import flash.events.UncaughtErrorEvent;
import flash.external.ExternalInterface;
