         
         // Event for Automation so we know when windows 
         // are created or destroyed.
-        if (ApplicationGlobals.application)
-        {
-            ApplicationGlobals.application.dispatchEvent(
+        if (FlexGlobals.topLevelApplication)
+        {
+            FlexGlobals.topLevelApplication.dispatchEvent(
                 new WindowExistenceEvent(WindowExistenceEvent.WINDOW_CLOSE, 
                                          false, false, this));
         }


import mx.controls.Button;
import mx.controls.FlexNativeMenu;
import mx.core.windowClasses.StatusBar;
import mx.core.windowClasses.TitleBar;
import mx.events.AIREvent;
import mx.events.FlexEvent;
import mx.events.FlexNativeWindowBoundsEvent;
import mx.events.WindowExistenceEvent;
import mx.managers.CursorManagerImpl;

            
            // Event for Automation so we know when windows 
            // are created or destroyed.
            if (FlexGlobals.topLevelApplication)
            {
                FlexGlobals.topLevelApplication.dispatchEvent(
                    new WindowExistenceEvent(WindowExistenceEvent.WINDOW_CREATE, 
                                             false, false, this));
            }
