 import flash.ui.ContextMenuItem;
 import flash.utils.setInterval;
 
+import mx.core.EventPriority;
 import mx.core.FlexGlobals;
 import mx.core.IInvalidating;
 import mx.core.InteractionMode;

                systemManager.removeEventListener(Event.RESIZE, resizeHandler);
                resizeHandlerAdded = false;
            }
        }

        if (percentBoundsChanged)

        
        synchronousResize = (parseFloat(version[0]) > 10 ||
                             (parseFloat(version[0]) == 10 && parseFloat(version[1]) >= 1)) && (Capabilities.playerType != "Desktop" || runningOnMobile);
    }
    
    /**
     *  @private
     *  Called if resizeForSoftKeyboard is true and the softKeyboard
     *  has been activated. 
     */    
    private function softKeyboardActivateHandler(event:SoftKeyboardEvent):void
    {
        if (this === FlexGlobals.topLevelApplication)
        {
            // Get the keyboard size
            var keyboardRect:Rectangle = stage.softKeyboardRect;
                        
            var sm:SystemManager = systemManager as SystemManager;
            var scaleFactor:Number = 1;
            
            // Account for any density scaling
            if (sm)
                scaleFactor = sm.densityScale;
            
            var appHeight:Number = (stage.stageHeight - keyboardRect.height) / scaleFactor;
            
            if (appHeight != height)
            {                
                setActualSize(width, appHeight);
                validateNow(); // Validate so that other listeners like Scroller get the updated dimensions
            }
        }
    }
    
    /**
     *  @private
     *  Called if resizeForSoftKeyboard is true and the softKeyboard
     *  has been deactivated. 
     */ 
    private function softKeyboardDeactivateHandler(event:SoftKeyboardEvent):void
    {
        if (this === FlexGlobals.topLevelApplication)
        {
            // Get the keyboard size
            var keyboardRect:Rectangle = stage.softKeyboardRect;
            
            var sm:SystemManager = systemManager as SystemManager;
            var scaleFactor:Number = 1;
            
            // Account for any density scaling
            if (sm)
                scaleFactor = sm.densityScale;
            
            // Restore the original values
            setActualSize(stage.stageWidth / scaleFactor, stage.stageHeight / scaleFactor);
            
            validateNow(); // Validate so that other listeners like Scroller get the updated dimensions
        }
    }
    
    /**
     *  Helper function to get the AIR application descriptor attribute called "softKeyboardBehavior". 
     */  
    mx_internal static function get softKeyboardBehavior():String
    {
        if (_softKeyboardBehavior != null)
        {
            return _softKeyboardBehavior;
        }
        else
        {
            // Since we might not be running on AIR, need to get the class by name. 
            // Also, make sure to cache the value so we only run this once
            var nativeApp:Object = FlexGlobals.topLevelApplication.systemManager.getDefinitionByName("flash.desktop.NativeApplication");
            
            if (nativeApp)
            {
                var appXML:XML = XML(nativeApp["nativeApplication"]["applicationDescriptor"]);
                var ns:Namespace = appXML.namespace();
                
                _softKeyboardBehavior = String(appXML..ns::softKeyboardBehavior);
            }
            else
            {
                _softKeyboardBehavior = "";
            }
            
            return _softKeyboardBehavior;
        }
    }

    //--------------------------------------------------------------------------
