                 
                 validateNow(); // Validate so that other listeners like Scroller get the updated dimensions
             }
+        }
+    }
+    
+    /**
+     *  @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.
+     */ 
+    private function softKeyboardTarget_removeFromStageHandler(event:Event):void
+    {
+        if (stage.focus == softKeyboardTarget)
+            stage.focus = null;
+        
+        // clearSoftKeyboardTarget() is called in response to the SOFT_KEYBOARD_DEACTIVATE
+        // event and will clear the removeFromStage listener and softKeyboardDeactivate 
+        // events from the target.
+    }
+    
+    /**
+     *  @private
+     *  This method clears the cached softKeyboard target and removes the
+     *  removeFromStage handler that is added in the softKeyboardActivateHandler
+     *  method.
+     */
+    private function clearSoftKeyboardTarget():void
+    {
+        if (softKeyboardTarget)
+        {
+            if (isIOS)
+            {
+                softKeyboardTarget.removeEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE, 
+                                                       softKeyboardDeactivateHandler);
+            }
+            
+            softKeyboardTarget.removeEventListener(Event.REMOVED_FROM_STAGE, softKeyboardTarget_removeFromStageHandler);
+            softKeyboardTarget = null;
         }
     }
     

    
    /**
     *  @private
     *  Flag set to true if the application has temporarily set its explicit
     *  width and height to deal with orientation.
     */ 

    {        
        if (this === FlexGlobals.topLevelApplication)
        {
            if (softKeyboardTarget && softKeyboardTarget != event.target)
                clearSoftKeyboardTarget();
            
            softKeyboardTarget = event.target;
            
            // If the display object that activates the softkeyboard is removed without
            // losing focus, the runtime may not dispatch a deactivate event.  So the
            // framework adds a REMOVE_FROM_STAGE event listener to the target and manually
            // clears the focus.
            softKeyboardTarget.addEventListener(Event.REMOVED_FROM_STAGE, 
                                                softKeyboardTarget_removeFromStageHandler, 
                                                false, EventPriority.DEFAULT, true);
            
            // On iOS, if the softKeyboard target is removed from the stage as a result
            // of a user input with another focusable component, the application will not
            // receive a SOFT_KEYBOARD_DEACTIVATE event, only the target will.
            if (isIOS)
            {
                softKeyboardTarget.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE, 
                                                    softKeyboardDeactivateHandler, false, 
                                                    EventPriority.DEFAULT, true);
            }
            
            // Get the keyboard size
            var keyboardRect:Rectangle = stage.softKeyboardRect;
     
