             window_displayStateChangeHandler)
         systemManager.stage.nativeWindow.addEventListener(
             "closing", window_closingHandler);
-
+        systemManager.stage.nativeWindow.addEventListener(
+            "close", window_closeHandler, false, 0, true);
+            
+        // For the edge case, e.g. visible is set to true in
+        // AIR xml file, we fabricate an activate event, since Flex 
+        // comes in late to the show.
+        if (systemManager.stage.nativeWindow.active) 
+            dispatchEvent(new Event("windowActivate"));
+                        
+        systemManager.stage.nativeWindow.addEventListener(
+            "activate", nativeWindow_activateHandler, false, 0, true);
+        systemManager.stage.nativeWindow.addEventListener(
+            "deactivate", nativeWindow_deactivateHandler, false, 0, true);
+                        
         systemManager.stage.nativeWindow.addEventListener(
             NativeWindowBoundsEvent.MOVING, window_boundsHandler);
 

    /**
     *  @private
     */
    private function window_resizeHandler(event:NativeWindowBoundsEvent):void
    {
        windowBoundsChanged= true;

    	else
    		dispatchEvent(event);
    }
    
    /**
     * @private
 	 */
 	private function nativeWindow_activateHandler(event:Event):void
 	{
 		dispatchEvent(new Event("windowActivate"));
 	}

 	/**
 	 *  @private
 	 */
 	private function nativeWindow_deactivateHandler(event:Event):void
 	{
 		dispatchEvent(new Event("windowDeactivate"));
 	}
 	
    /**
     *  This is a temporary event handler which dispatches a initialLayoutComplete event after
     *  two updateCompletes. This event will only be dispatched after either setting the bounds or
