Transferred from the Adobe Open Source Subversion Repository

Revision: 6125
Author:   dloverin@adobe.com
Date:     2009-04-10T15:07:49.535097Z

Log Message:
-----------
Complete Spark WindowedApplication and Spark Window.

* When you turn System Chrome off you do not get Flex Chrome automatically anymore. You need to set the skinClass style to use FlexChromeSkin. This means if System Chrome is not present the WindowedApplication will not have chrome.

* FlexChromeSkin brightens/dims its chrome depending on its active/inactive state.

* The TitleBarSkin was split into two skins, TitleBarSkin and MacTitleBarSkin. TitleBarSkin has just the Windows look. MacTitleBarSkin has the mac look. TitleBar will automatically switch between the skins depending on the OS.

* Implemented titleIcon in TitleBar.

* titleText in the TitleBarSkin and the MacTitleBarSkin is truncated when the text doesn't fit in the Window.

* statusText in FlexChromeSkin is truncated if the text does not fit with the status bar.

QE Notes: Ready for testing.
Doc Notes: None
Bugs:
Reviewer: Ryan, Glenn
tests: checkintests

Modified Paths:
--------------
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/mx/core/Window.as</path>
<path kind="file" action="A">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/skins/default/FlexChromeSkin.mxml</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/skins/default/MacMinimizeButtonSkin.mxml</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/skins/default/MacMaximizeButtonSkin.mxml</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/skins/default/CloseButtonSkin.mxml</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/skins/default/WindowedApplicationSkin.mxml</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/skins/default/TitleBarSkin.mxml</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/components/windowClasses/TitleBar.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/mx/managers/WindowedSystemManager.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/skins/default/GripperSkin.mxml</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/spark-air-manifest.xml</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/defaults.css</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/skins/default/MinimizeButtonSkin.mxml</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/mx/events/WindowExistenceEvent.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/components/WindowedApplication.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/skins/default/MaximizeButtonSkin.mxml</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/skins/default/RestoreButtonSkin.mxml</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/skins/default/MacCloseButtonSkin.mxml</path>
<path kind="file" action="A">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/components/Window.as</path>
<path kind="file" action="A">/flex/sdk/trunk/frameworks/projects/airframework/src/spark/skins/default/MacTitleBarSkin.mxml</path>

git-svn-id: 7146a936b37d36e51ea0d66f8acbe0b8281bc7b7@1250499 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/airspark/src/spark/components/Window.as
+++ frameworks/projects/airspark/src/spark/components/Window.as
@@ -0,0 +1,2950 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  ADOBE SYSTEMS INCORPORATED
+//  Copyright 2007 Adobe Systems Incorporated
+//  All Rights Reserved.
+//
+//  NOTICE: Adobe permits you to use, modify, and distribute this file
+//  in accordance with the terms of the license agreement accompanying it.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package spark.components
+{
+
+import flash.desktop.NativeApplication;
+import flash.display.DisplayObject;
+import flash.display.Graphics;
+import flash.display.NativeWindow;
+import flash.display.NativeWindowDisplayState;
+import flash.display.NativeWindowInitOptions;
+import flash.display.NativeWindowResize;
+import flash.display.Sprite;
+import flash.events.Event;
+import flash.events.MouseEvent;
+import flash.events.NativeWindowBoundsEvent;
+import flash.events.NativeWindowDisplayStateEvent;
+import flash.geom.Point;
+import flash.geom.Rectangle;
+
+import mx.controls.FlexNativeMenu;
+import mx.core.ContainerCreationPolicy;
+import mx.core.FlexGlobals;
+import mx.core.IWindow;
+import mx.core.mx_internal;
+import mx.core.UIComponent;
+import mx.events.AIREvent;
+import mx.events.FlexEvent;
+import mx.events.FlexNativeWindowBoundsEvent;
+import mx.events.WindowExistenceEvent;
+import mx.managers.CursorManagerImpl;
+import mx.managers.DragManager;
+import mx.managers.FocusManager;
+import mx.managers.ICursorManager;
+import mx.managers.ISystemManager;
+import mx.managers.NativeDragManagerImpl;
+import mx.managers.WindowedSystemManager;
+import mx.styles.CSSStyleDeclaration;
+import mx.styles.StyleManager;
+
+import spark.components.Application;
+import spark.components.Button;
+import spark.components.Group;
+import spark.primitives.Rect;
+import spark.primitives.SimpleText;
+import spark.components.windowClasses.TitleBar;
+
+use namespace mx_internal;
+
+//--------------------------------------
+//  Events
+//--------------------------------------
+
+/**
+ *  Dispatched when this application gets activated.
+ *
+ *  @eventType mx.events.AIREvent.APPLICATION_ACTIVATE
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="applicationActivate", type="mx.events.AIREvent")]
+
+/**
+ *  Dispatched when this application gets deactivated.
+ *
+ *  @eventType mx.events.AIREvent.APPLICATION_DEACTIVATE
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="applicationDeactivate", type="mx.events.AIREvent")]
+
+/**
+ *  Dispatched after the window has been activated.
+ *
+ *  @eventType mx.events.AIREvent.WINDOW_ACTIVATE
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="windowActivate", type="mx.events.AIREvent")]
+
+/**
+ *  Dispatched after the window has been deactivated.
+ *
+ *  @eventType mx.events.AIREvent.WINDOW_DEACTIVATE
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="windowDeactivate", type="mx.events.AIREvent")]
+
+/**
+ *  Dispatched after the window has been closed.
+ *
+ *  @eventType flash.events.Event.CLOSE
+ *
+ *  @see flash.display.NativeWindow
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="close", type="flash.events.Event")]
+
+/**
+ *  Dispatched before the window closes.
+ *  This event is cancelable.
+ *
+ *  @eventType flash.events.Event.CLOSING
+ *
+ *  @see flash.display.NativeWindow
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="closing", type="flash.events.Event")]
+
+/**
+ *  Dispatched after the display state changes
+ *  to minimize, maximize or restore.
+ *
+ *  @eventType flash.events.NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="displayStateChange", type="flash.events.NativeWindowDisplayStateEvent")]
+
+/**
+ *  Dispatched before the display state changes
+ *  to minimize, maximize or restore.
+ *
+ *  @eventType flash.events.NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="displayStateChanging", type="flash.events.NativeWindowDisplayStateEvent")]
+
+/**
+ *  Dispatched before the window moves,
+ *  and while the window is being dragged.
+ *
+ *  @eventType flash.events.NativeWindowBoundsEvent.MOVING
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="moving", type="flash.events.NativeWindowBoundsEvent")]
+
+/**
+ *  Dispatched when the computer connects to or disconnects from the network.
+ *
+ *  @eventType flash.events.Event.NETWORK_CHANGE
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="networkChange", type="flash.events.Event")]
+
+/**
+ *  Dispatched before the underlying NativeWindow is resized, or
+ *  while the Window object boundaries are being dragged.
+ *
+ *  @eventType flash.events.NativeWindowBoundsEvent.RESIZING
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="resizing", type="flash.events.NativeWindowBoundsEvent")]
+
+/**
+ *  Dispatched when the Window completes its initial layout
+ *  and opens the underlying NativeWindow.
+ *
+ *  @eventType mx.events.AIREvent.WINDOW_COMPLETE
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="windowComplete", type="mx.events.AIREvent")]
+
+/**
+ *  Dispatched after the window moves.
+ *
+ *  @eventType mx.events.FlexNativeWindowBoundsEvent.WINDOW_MOVE
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="windowMove", type="mx.events.FlexNativeWindowBoundsEvent")]
+
+/**
+ *  Dispatched after the underlying NativeWindow is resized.
+ *
+ *  @eventType mx.events.FlexNativeWindowBoundsEvent.WINDOW_RESIZE
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="windowResize", type="mx.events.FlexNativeWindowBoundsEvent")]
+
+//--------------------------------------
+//  Effects
+//--------------------------------------
+
+/**
+ *  Played when the window is closed.
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Effect(name="closeEffect", event="windowClose")]
+
+/**
+ *  Played when the component is minimized.
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Effect(name="minimizeEffect", event="windowMinimize")]
+
+/**
+ *  Played when the component is unminimized.
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Effect(name="unminimizeEffect", event="windowUnminimize")]
+
+//--------------------------------------
+//  Excluded APIs
+//--------------------------------------
+
+[Exclude(name="moveEffect", kind="effect")]
+
+//--------------------------------------
+//  SkinStates
+//--------------------------------------
+
+/**
+ *  The application is enabled and active.
+ *
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+[SkinState("normal")]
+
+/**
+ *  The application is disabled and active.
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+[SkinState("disabled")]
+
+/**
+ *  The application is enabled and inactive.
+ *
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+[SkinState("normalActive")]
+
+/**
+ *  The application is disabled and inactive.
+ *
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+[SkinState("disabledInactive")]
+
+//--------------------------------------
+//  Other metadata
+//--------------------------------------
+
+/**
+ *  The frameworks must be initialized by SystemManager.
+ *  This factoryClass will be automatically subclassed by any
+ *  MXML applications that don't explicitly specify a different
+ *  factoryClass.
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Frame(factoryClass="mx.managers.WindowedSystemManager")]
+
+[IconFile("../../mx/core/Window.png")]
+
+[ResourceBundle("core")]
+
+/**
+ *  The Window is a top-level container for additional windows
+ *  in an AIR desktop application.
+ *
+ *
The Window container is a special kind of container in the sense
+ *  that it cannot be used within other layout containers. An mx:Window
+ *  component must be the top-level component in its MXML document.

+ *
+ *
The easiest way to use a Window component to define a native window is to
+ *  create an MXML document with an <mx:Window> tag
+ *  as the top-level tag in the document. You use the Window component
+ *  just as you do any other container, including specifying the layout
+ *  type, defining child controls, and so forth. Like any other custom
+ *  MXML component, when your application is compiled your MXML document
+ *  is compiled into a custom class that is a subclass of the Window
+ *  component.

+ *
+ *
In your application code, to make an instance of
+ *  your Window subclass appear on the screen you first create an instance
+ *  of the class in code (by defining a variable and calling the new
+ *  MyWindowClass() constructor. Next you set any properties you wish
+ *  to specify for the new window. Finally you call your Window component's
+ *  open() method to open the window on the screen.

+ *
+ *
Note that several of the Window class's properties can only be set
+ *  before calling the open() method to open
+ *  the window. Once the underlying NativeWindow is created, these initialization
+ *  properties can be read but cannot be changed. This restriction applies to
+ *  the following properties:

+ *
+ *

+ *
maximizable

+ *
minimizable

+ *
resizable

+ *
systemChrome

+ *
transparent

+ *
type

+ *

+ *
+ *  @mxml
+ *
+ *
The <mx:Window> tag inherits all of the tag
+ *  attributes of its superclass and adds the following tag attributes:

+ *
+ *

+ *  <mx:Window
+ *    Properties
+ *    alwaysInFront="false"
+ *    backgroundColor="white"
+ *    colorCorrection="default"
+ *    height="100"
+ *    maxHeight="10000"
+ *    maximizable="true"
+ *    maxWidth="10000"
+ *    menu="null"
+ *    minHeight="0"
+ *    minimizable="true"
+ *    minWidth="0"
+ *    resizable="true"
+ *    showGripper="true"
+ *    showStatusBar="true"
+ *    showTitleBar="true"
+ *    status=""
+ *    systemChrome="standard"
+ *    title=""
+ *    titleIcon="null"
+ *    transparent="false"
+ *    type="normal"
+ *    visible="true"
+ *    width="100"
+ *
+ *    Effects
+ *    closeEffect="No default"
+ *    minimizeEffect="No default"
+ *    unminimizeEffect="No default"
+ *
+ *    Events
+ *    applicationActivate="No default"
+ *    applicationDeactivate="No default"
+ *    closing="No default"
+ *    displayStateChange="No default"
+ *    displayStateChanging="No default"
+ *    moving="No default"
+ *    networkChange="No default"
+ *    resizing="No default"
+ *    windowComplete="No default"
+ *    windowMove="No default"
+ *    windowResize="No default"
+ *  />
+ *

+ *
+ *  @see spark.components.WindowedApplication
+ *
+ *
+ *  @langversion 3.0
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+public class Window extends SkinnableContainer implements IWindow
+{
+    include "../../mx/core/Version.as";
+
+    //--------------------------------------------------------------------------
+    //
+    //  Class constants
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  The default height for a window (SDK-14399)
+     *  @private
+     */
+    private static const DEFAULT_WINDOW_HEIGHT:Number = 100;
+
+    /**
+     *  The default width for a window (SDK-14399)
+     *  @private
+     */
+    private static const DEFAULT_WINDOW_WIDTH:Number = 100;
+
+    //--------------------------------------------------------------------------
+    //
+    //  Class methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Returns the Window to which a component is parented.
+     *
+     *  @param component the component whose Window you wish to find.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public static function getWindow(component:UIComponent):IWindow
+    {
+        if (component.systemManager is WindowedSystemManager)
+            return WindowedSystemManager(component.systemManager).window;
+
+        return null;
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Constructor
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Constructor.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function Window()
+    {
+        super();
+
+        addEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler);
+        addEventListener(FlexEvent.PREINITIALIZE, preinitializeHandler);
+
+        invalidateProperties();
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Variables
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    private var _nativeWindow:NativeWindow;
+
+    /**
+     *  @private
+     */
+    private var _nativeWindowVisible:Boolean = true;
+
+    /**
+     *  @private
+     */
+    private var maximized:Boolean = false;
+
+    /**
+     *  @private
+     */
+    private var _cursorManager:ICursorManager;
+
+
+    /**
+     *  @private
+     */
+    private var toMax:Boolean = false;
+
+    /**
+     *  @private
+     *  Ensures that the Window has finished drawing
+     *  before it becomes visible.
+     */
+    private var frameCounter:int = 0;
+
+    /**
+     *  @private
+     */
+    private var flagForOpen:Boolean = false;
+
+    /**
+     *   @private
+     */
+    private var openActive:Boolean = true;
+
+    /**
+     *  @private
+     */
+    private var oldX:Number;
+
+    /**
+     *  @private
+     */
+    private var oldY:Number;
+
+    /**
+     *  @private
+     */
+    private var prevX:Number;
+
+    /**
+     *  @private
+     */
+    private var prevY:Number;
+
+    /**
+     *  @private
+     */
+    private var resizeHandlerAdded:Boolean = false;
+
+    /**
+     *  @private
+     *  This flag indicates whether the width of the Application instance
+     *  can change or has been explicitly set by the developer.
+     *  When the stage is resized we use this flag to know whether the
+     *  width of the Application should be modified.
+     */
+    private var resizeWidth:Boolean = true;
+
+    /**
+     *  @private
+     *  This flag indicates whether the height of the Application instance
+     *  can change or has been explicitly set by the developer.
+     *  When the stage is resized we use this flag to know whether the
+     *  height of the Application should be modified.
+     */
+    private var resizeHeight:Boolean = true;
+
+    //--------------------------------------------------------------------------
+    //
+    //  Skin Parts
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  The SkinPart that displays the border.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    [SkinPart (required = "false")]
+    public var border:Group;
+
+    /**
+     *  The SkinPart that contains the titlebar, the content, and the status bar.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    [SkinPart (required = "false")]
+    public var chromeAndContent:Group;
+
+    /**
+     *  A skin part that defines the gripper button used to resize the window.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    [SkinPart (required="false")]
+    public var gripper:Button;
+
+    /**
+     *  The SkinPart that displays the status bar.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    [SkinPart (required = "false")]
+    public var statusBar:Group;
+
+    //----------------------------------
+    //  statusText
+    //----------------------------------
+
+    /**
+     *  A reference to the UITextField that displays the status bar's text.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    [SkinPart (required="false")]
+    public var statusText:SimpleText;
+
+    /**
+     *  The UIComponent that displays the title bar.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    [SkinPart (required="false")]
+    public var titleBar:TitleBar;
+
+    /**
+     *  The background behind the title bar. A white background
+     *  is placed behind the title bar because the title bar has
+     *  its alpha property set to 0.5 when the application is
+     *  inactive.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    [SkinPart (required="false")]
+    public var titleBarBackgroundRect:Rect;
+
+
+    //--------------------------------------------------------------------------
+    //
+    //  Overridden properties: UIComponent
+    //
+    //--------------------------------------------------------------------------
+
+    //----------------------------------
+    //  height
+    //----------------------------------
+
+    [Bindable("heightChanged")]
+    [Inspectable(category="General")]
+    [PercentProxy("percentHeight")]
+
+    /**
+     *  @private
+     */
+    override public function get height():Number
+    {
+        return _bounds.height;
+    }
+
+    /**
+     *  @private
+     *  Also sets the stage's height.
+     */
+    override public function set height(value:Number):void
+    {
+        if (value < minHeight)
+            value = minHeight;
+        else if (value > maxHeight)
+            value = maxHeight;
+
+        _bounds.height = value;
+        boundsChanged = true;
+
+        invalidateProperties();
+        invalidateSize();
+
+        dispatchEvent(new Event("heightChanged"));
+        // also dispatched in the resizeHandler
+    }
+
+    //----------------------------------
+    //  maxHeight
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the maxHeight property.
+     */
+    private var _maxHeight:Number = 10000;
+
+    /**
+     *  @private
+     *  Keeps track of whether maxHeight property changed so we can
+     *  handle it in commitProperties.
+     */
+    private var maxHeightChanged:Boolean = false;
+
+    [Bindable("maxHeightChanged")]
+    [Bindable("windowComplete")]
+
+    /**
+     *  @private
+     */
+    override public function get maxHeight():Number
+    {
+        if (nativeWindow && !maxHeightChanged)
+            return nativeWindow.maxSize.y - chromeHeight();
+        else
+            return _maxHeight;
+    }
+
+    /**
+     *  Specifies the maximum height of the application's window.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    override public function set maxHeight(value:Number):void
+    {
+        _maxHeight = value;
+        maxHeightChanged = true;
+        invalidateProperties();
+    }
+
+    //----------------------------------
+    //  maxWidth
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the maxWidth property.
+     */
+    private var _maxWidth:Number = 10000;
+
+    /**
+     *  @private
+     *  Keeps track of whether maxWidth property changed so we can
+     *  handle it in commitProperties.
+     */
+    private var maxWidthChanged:Boolean = false;
+
+    [Bindable("maxWidthChanged")]
+    [Bindable("windowComplete")]
+
+    /**
+     *  @private
+     */
+    override public function get maxWidth():Number
+    {
+        if (nativeWindow && !maxWidthChanged)
+            return nativeWindow.maxSize.x - chromeWidth();
+        else
+            return _maxWidth;
+    }
+
+    /**
+     *  Specifies the maximum width of the application's window.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    override public function set maxWidth(value:Number):void
+    {
+        _maxWidth = value;
+        maxWidthChanged = true;
+        invalidateProperties();
+    }
+
+     //---------------------------------
+     //  minHeight
+     //---------------------------------
+
+    /**
+     *  @private
+     */
+    private var _minHeight:Number = 0;
+
+    /**
+     *  @private
+     *  Keeps track of whether minHeight property changed so we can
+     *  handle it in commitProperties.
+     */
+    private var minHeightChanged:Boolean = false;
+
+    [Bindable("minHeightChanged")]
+    [Bindable("windowComplete")]
+
+    /**
+     *  Specifies the minimum height of the application's window.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    override public function get minHeight():Number
+    {
+        if (nativeWindow && !minHeightChanged)
+            return nativeWindow.minSize.y - chromeHeight();
+        else
+            return _minHeight;
+    }
+
+    /**
+     *  @private
+     */
+    override public function set minHeight(value:Number):void
+    {
+        _minHeight = value;
+        minHeightChanged = true;
+        invalidateProperties();
+    }
+
+     //---------------------------------
+     //  minWidth
+     //---------------------------------
+
+    /**
+     *  @private
+     *  Storage for the minWidth property.
+     */
+    private var _minWidth:Number = 0;
+
+   /**
+     *  @private
+     *  Keeps track of whether minWidth property changed so we can
+     *  handle it in commitProperties.
+     */
+    private var minWidthChanged:Boolean = false;
+
+    [Bindable("minWidthChanged")]
+    [Bindable("windowComplete")]
+
+    /**
+     *  Specifies the minimum width of the application's window.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    override public function get minWidth():Number
+    {
+        if (nativeWindow && !minWidthChanged)
+            return nativeWindow.minSize.x - chromeWidth();
+        else
+            return _minWidth;
+    }
+
+    /**
+     *  @private
+     */
+    override public function set minWidth(value:Number):void
+    {
+        _minWidth = value;
+        minWidthChanged = true;
+        invalidateProperties();
+    }
+
+    //----------------------------------
+    //  visible
+    //----------------------------------
+
+    [Bindable("hide")]
+    [Bindable("show")]
+    [Bindable("windowComplete")]
+
+    /**
+     *  Controls the window's visibility. Unlike the
+     *  UIComponent.visible property of most Flex
+     *  visual components, this property affects the visibility
+     *  of the underlying NativeWindow (including operating system
+     *  chrome) as well as the visibility of the Window's child
+     *  controls.
+     *
+     *
When this property changes, Flex dispatches a show
+     *  or hide event.

+     *
+     *  @default true
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    override public function get visible():Boolean
+    {
+        if (!nativeWindow.closed)
+            return _nativeWindow.visible;
+        else
+            return false;
+    }
+    /**
+     *  @private
+     */
+    override public function set visible(value:Boolean):void
+    {
+        if (!_nativeWindow)
+        {
+            _nativeWindowVisible = value;
+            invalidateProperties();
+        }
+        else if (!_nativeWindow.closed)
+        {
+            var e:FlexEvent;
+            if (value)
+            {
+                _nativeWindow.visible = value;
+                e = new FlexEvent(FlexEvent.SHOW);
+                dispatchEvent(e);
+            }
+            else
+            {
+                e = new FlexEvent(FlexEvent.HIDE);
+                if (getStyle("hideEffect"))
+                {
+                    addEventListener("effectEnd", hideEffectEndHandler);
+                }
+                else
+                {
+                    _nativeWindow.visible = value;
+                    dispatchEvent(e);
+                }
+            }
+        }
+    }
+
+    //----------------------------------
+    //  width
+    //----------------------------------
+
+    [Bindable("widthChanged")]
+    [Inspectable(category="General")]
+    [PercentProxy("percentWidth")]
+
+    /**
+     *  @private
+     */
+    override public function get width():Number
+    {
+        return _bounds.width;
+    }
+
+    /**
+     *  @private
+     *  Also sets the stage's width.
+     */
+    override public function set width(value:Number):void
+    {
+        if (value < minWidth)
+            value = minWidth;
+        else if (value > maxWidth)
+            value = maxWidth;
+
+        _bounds.width = value;
+        boundsChanged = true;
+
+        invalidateProperties();
+        invalidateSize();
+
+        dispatchEvent(new Event("widthChanged"));
+        // also dispatched in the resize handler
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Properties
+    //
+    //--------------------------------------------------------------------------
+
+    //----------------------------------
+    // alwaysInFront
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the alwaysInFront property.
+     */
+    private var _alwaysInFront:Boolean = false;
+
+    /**
+     *  Determines whether the underlying NativeWindow is always in front
+     *  of other windows (including those of other applications). Setting
+     *  this property sets the alwaysInFront property of the
+     *  underlying NativeWindow. See the NativeWindow.alwaysInFront
+     *  property description for details of how this affects window stacking
+     *  order.
+     *
+     *  @see flash.display.NativeWindow#alwaysInFront
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get alwaysInFront():Boolean
+    {
+        if (_nativeWindow && !_nativeWindow.closed)
+            return nativeWindow.alwaysInFront;
+        else
+            return _alwaysInFront;
+    }
+
+    /**
+     *  @private
+     */
+    public function set alwaysInFront(value:Boolean):void
+    {
+        _alwaysInFront = value;
+        if (_nativeWindow && !_nativeWindow.closed)
+            nativeWindow.alwaysInFront = value;
+    }
+
+    //----------------------------------
+    //  backgroundColor
+    //----------------------------------
+
+    [Inspectable(category="General", format="Color")]
+    [Bindable("backgroundColorUpdated")]
+
+    /**
+     *  Background color of a component.
+     *  This property specifies the background color, both while the application
+     *  loads, and while it is running.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get backgroundColor():uint
+    {
+        return getStyle("backgroundColor");
+    }
+
+    /**
+     * @private
+     */
+    public function set backgroundColor(value:uint):void
+    {
+        if (value == getStyle("backgroundColor"))
+            return;
+
+        setStyle("backgroundColor", value);
+
+        dispatchEvent(new Event("backgroundColorUpdated"));
+    }
+
+    //----------------------------------
+    //  bounds
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the bounds property.
+     */
+    private var _bounds:Rectangle = new Rectangle(0, 0, DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
+
+    /**
+     *  @private
+     */
+    private var boundsChanged:Boolean = false;
+
+    /**
+     *  @private
+     *  A Rectangle specifying the window's bounds
+     *  relative to the screen.
+     */
+    protected function get bounds():Rectangle
+    {
+        return _bounds;
+    }
+
+    /**
+     *  @private
+     */
+    protected function set bounds(value:Rectangle):void
+    {
+        _bounds = value;
+        boundsChanged = true;
+
+        invalidateProperties();
+        invalidateSize();
+    }
+
+    //----------------------------------
+    //  closed
+    //----------------------------------
+
+    /**
+     *  A flag indicating whether the window has been closed.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get closed():Boolean
+    {
+        return nativeWindow.closed;
+    }
+
+    //----------------------------------
+    //  colorCorrection
+    //----------------------------------
+
+    [Inspectable(enumeration="default,off,on", defaultValue="default" )]
+
+   /**
+    *  The value of the stage's colorCorrection property. If this application
+    *  does not have access to the stage's colorCorrection property,
+    *  the value of the colorCorrection property will be reported as
+    *  null. Only the main application is allowed to set the colorCorrection
+    *  property. If a sub-application's needs to set the color correction property it will
+    *  need to set it via the main application's instance, either directly using an object
+    *  instance or via an event (there is no framework event for this purpose).
+    *
+    *  @default ColorCorrection.DEFAULT
+    *
+    *  @langversion 3.0
+    *  @playerversion Flash 10
+    *  @playerversion AIR 1.5
+    *  @productversion Flex 4
+    */
+    public function get colorCorrection():String
+    {
+        try
+        {
+            var sm:ISystemManager = systemManager;
+            if (sm && sm.stage)
+                return sm.stage.colorCorrection;
+        }
+        catch (e:SecurityError)
+        {
+            // ignore error if this application is not allow
+            // to view the colorCorrection property.
+        }
+
+        return null;
+    }
+
+    //----------------------------------
+    //  maximizable
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the maximizable property.
+     */
+    private var _maximizable:Boolean = true;
+
+    /**
+     *  Specifies whether the window can be maximized.
+     *  This property's value is read-only after the window
+     *  has been opened.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get maximizable():Boolean
+    {
+        return _maximizable;
+    }
+
+    /**
+     *  @private
+     */
+    public function set maximizable(value:Boolean):void
+    {
+        if (!_nativeWindow)
+        {
+            _maximizable = value;
+
+            invalidateProperties();
+        }
+    }
+
+    //----------------------------------
+    //  menu
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the menu property.
+     */
+    private var _menu:FlexNativeMenu;
+
+    //----------------------------------
+    //  cursorManager
+    //----------------------------------
+    /**
+     *  Returns the cursor manager for this Window.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    override public function get cursorManager():ICursorManager
+    {
+        return _cursorManager;
+    }
+
+
+    /**
+     *  @private
+     */
+    private var menuChanged:Boolean = false;
+
+    /**
+     *  @private
+     */
+    public function get menu():FlexNativeMenu
+    {
+        return _menu;
+    }
+
+    /**
+     *  The window menu for this window.
+     *  Some operating systems do not support window menus,
+     *  in which case this property is ignored.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function set menu(value:FlexNativeMenu):void
+    {
+        _menu = value;
+        menuChanged = true;
+    }
+
+    //----------------------------------
+    //  minimizable
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the minimizable property.
+     */
+    private var _minimizable:Boolean = true;
+
+    /**
+     *  Specifies whether the window can be minimized.
+     *  This property is read-only after the window has
+     *  been opened.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get minimizable():Boolean
+    {
+        return _minimizable;
+    }
+
+    /**
+     *  @private
+     */
+    public function set minimizable(value:Boolean):void
+    {
+        if (!_nativeWindow)
+        {
+            _minimizable = value;
+
+            invalidateProperties();
+        }
+    }
+
+    //----------------------------------
+    //  nativeWindow
+    //----------------------------------
+
+    /**
+     *  The underlying NativeWindow that this Window component uses.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get nativeWindow():NativeWindow
+    {
+        if (systemManager && systemManager.stage)
+            return systemManager.stage.nativeWindow;
+
+        return null;
+    }
+
+    //----------------------------------
+    //  resizable
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the resizable property.
+     */
+    private var _resizable:Boolean = true;
+
+    /**
+     *  Specifies whether the window can be resized.
+     *  This property is read-only after the window
+     *  has been opened.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get resizable():Boolean
+    {
+        return _resizable;
+    }
+
+    /**
+     *  @private
+     */
+    public function set resizable(value:Boolean):void
+    {
+
+        if (!_nativeWindow)
+        {
+            _resizable = value;
+
+            invalidateProperties();
+        }
+    }
+
+    //---------------------------------
+    //  resizeAffordance
+    //---------------------------------
+
+    /**
+     *  Provides a margin of error around the application's border so a resize
+     *  and be more easily started. A click on the application is considered a
+     *  click on the application's border if the click occurs with the resizeAffordance
+     *  number of pixels from the outside edge of the application's window.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public var resizeAffordance:Number = 6;
+
+    //----------------------------------
+    //  showGripper
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the showGripper property.
+     */
+    private var _showGripper:Boolean = true;
+
+    /**
+     *  @private
+     */
+    private var showGripperChanged:Boolean = true;
+
+    /**
+     *  If true, the gripper is visible.
+     *
+     *
On Mac OS X a window with systemChrome
+     *  set to "standard"
+     *  always has an operating system gripper, so this property is ignored
+     *  in that case.

+     *
+     *  @default true
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get showGripper():Boolean
+    {
+        return _showGripper;
+    }
+
+    /**
+     *  @private
+     */
+    public function set showGripper(value:Boolean):void
+    {
+        if (_showGripper == value)
+            return;
+
+        _showGripper = value;
+        showGripperChanged = true;
+
+        invalidateProperties();
+        invalidateDisplayList();
+    }
+
+    //----------------------------------
+    //  showStatusBar
+    //----------------------------------
+
+    /**
+     *  Storage for the showStatusBar property.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    private var _showStatusBar:Boolean = true;
+
+    /**
+     *  @private
+     */
+    private var showStatusBarChanged:Boolean = true;
+
+    /**
+     *  If true, the status bar is visible.
+     *
+     *  @default true
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get showStatusBar():Boolean
+    {
+        return _showStatusBar;
+    }
+
+    /**
+     *  @private
+     */
+    public function set showStatusBar(value:Boolean):void
+    {
+        if (_showStatusBar == value)
+            return;
+
+        _showStatusBar = value;
+        showStatusBarChanged = true;
+
+        invalidateProperties();
+        invalidateDisplayList();
+    }
+
+    //----------------------------------
+    //  showTitleBar
+    //----------------------------------
+
+    /**
+     *  Storage for the showTitleBar property.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    private var _showTitleBar:Boolean = true;
+
+    /**
+     *  @private
+     */
+    private var showTitleBarChanged:Boolean = true;
+
+    /**
+     *  If true, the window's title bar is visible.
+     *
+     *  @default true
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get showTitleBar():Boolean
+    {
+        return _showTitleBar;
+    }
+
+    /**
+     *  @private
+     */
+    public function set showTitleBar(value:Boolean):void
+    {
+        if (_showTitleBar == value)
+            return;
+
+        _showTitleBar = value;
+        showTitleBarChanged = true;
+
+        invalidateProperties();
+        invalidateDisplayList();
+    }
+
+    //----------------------------------
+    //  status
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the status property.
+     */
+    private var _status:String = "";
+
+    /**
+     *  @private
+     */
+    private var statusChanged:Boolean = false;
+
+    [Bindable("statusChanged")]
+
+    /**
+     *  The string that appears in the status bar, if it is visible.
+     *
+     *  @default ""
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get status():String
+    {
+        return _status;
+    }
+
+    /**
+     *  @private
+     */
+    public function set status(value:String):void
+    {
+
+        _status = value;
+        statusChanged = true;
+
+        invalidateProperties();
+        invalidateSize();
+
+        dispatchEvent(new Event("statusChanged"));
+    }
+
+    //----------------------------------
+    //  systemChrome
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the systemChrome property.
+     */
+    private var _systemChrome:String = "standard";
+
+    /**
+     *  Specifies the type of system chrome (if any) the window has.
+     *  The set of possible values is defined by the constants
+     *  in the NativeWindowSystemChrome class.
+     *
+     *
This property is read-only once the window has been opened.

+     *
+     *
The default value is NativeWindowSystemChrome.STANDARD.

+     *
+     *  @see flash.display.NativeWindowSystemChrome
+     *  @see flash.display.NativeWindowInitOptions#systemChrome
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get systemChrome():String
+    {
+        return _systemChrome;
+    }
+
+    /**
+     *  @private
+     */
+    public function set systemChrome(value:String):void
+    {
+        if (!_nativeWindow)
+        {
+            _systemChrome = value;
+
+            invalidateProperties();
+        }
+    }
+
+    //----------------------------------
+    //  title
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the title property.
+     */
+    private var _title:String = "";
+
+    /**
+     *  @private
+     */
+    private var titleChanged:Boolean = false;
+
+    [Bindable("titleChanged")]
+
+    /**
+     *  The title text that appears in the window title bar and
+     *  the taskbar.
+     *
+     *  @default ""
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get title():String
+    {
+        return _title;
+    }
+
+    /**
+     *  @private
+     */
+    public function set title(value:String):void
+    {
+        titleChanged = true;
+        _title = value;
+
+        invalidateProperties();
+        invalidateSize();
+        invalidateDisplayList();
+
+        dispatchEvent(new Event("titleChanged"));
+    }
+
+    //----------------------------------
+    //  titleIcon
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the titleIcon property.
+     */
+    private var _titleIcon:Class;
+
+    /**
+     *  @private
+     */
+    private var titleIconChanged:Boolean = false;
+
+    [Bindable("titleIconChanged")]
+
+    /**
+     *  The Class (usually an image) used to draw the title bar icon.
+     *
+     *  @default null
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get titleIcon():Class
+    {
+        return _titleIcon;
+    }
+
+    /**
+     *  @private
+     */
+    public function set titleIcon(value:Class):void
+    {
+        _titleIcon = value;
+        titleIconChanged = true;
+
+        invalidateProperties();
+        invalidateSize();
+        invalidateDisplayList();
+
+        dispatchEvent(new Event("titleIconChanged"));
+    }
+
+    //----------------------------------
+    //  transparent
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the transparent property.
+     */
+    private var _transparent:Boolean = false;
+
+    /**
+     *  Specifies whether the window is transparent. Setting this
+     *  property to true for a window that uses
+     *  system chrome is not supported.
+     *
+     *
This property is read-only after the window has been opened.

+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get transparent():Boolean
+    {
+        return _transparent;
+    }
+
+    /**
+     *  @private
+     */
+    public function set transparent(value:Boolean):void
+    {
+        if (!_nativeWindow)
+        {
+            _transparent = value;
+
+            invalidateProperties();
+        }
+    }
+
+    //----------------------------------
+    //  type
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the type property.
+     */
+    private var _type:String = "normal";
+
+    /**
+     *  Specifies the type of NativeWindow that this component
+     *  represents. The set of possible values is defined by the constants
+     *  in the NativeWindowType class.
+     *
+     *
This property is read-only once the window has been opened.

+     *
+     *
The default value is NativeWindowType.NORMAL.

+     *
+     *  @see flash.display.NativeWindowType
+     *  @see flash.display.NativeWindowInitOptions#type
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get type():String
+    {
+        return _type;
+    }
+
+    /**
+     *  @private
+     */
+    public function set type(value:String):void
+    {
+        if (!_nativeWindow)
+        {
+            _type = value;
+
+            invalidateProperties();
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Overridden methods: SkinnableContainer
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    override protected function partAdded(partName:String, instance:Object):void
+    {
+        super.partAdded(partName, instance);
+
+        if (instance == titleBar)
+        {
+            if (!nativeWindow.closed)
+                systemManager.stage.nativeWindow.title = _title;
+            titleBar.title = _title;
+            titleChanged = false;
+        }
+        else if (instance == statusText)
+        {
+            statusText.text = status;
+            statusChanged = false;
+        }
+        else if (instance == gripper)
+        {
+            gripper.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
+        }
+        else if (instance == border)
+        {
+        	// listen for mouse hits so we can reside the window
+            border.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
+        }
+    }
+
+    /**
+     *  @private
+     */
+    override protected function partRemoved(partName:String, instance:Object):void
+    {
+    	super.partRemoved(partName, instance);
+
+        if (instance == gripper)
+        {
+            gripper.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
+        }
+        else if (instance == border)
+        {
+        	// listen for mouse hits so we can reside the window
+            border.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Overridden methods: UIComponent
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    override public function initialize():void
+    {
+        var sm:ISystemManager = systemManager;
+        if (documentDescriptor)
+        {
+            creationPolicy = documentDescriptor.properties.creationPolicy;
+            if (creationPolicy == null || creationPolicy.length == 0)
+                creationPolicy = ContainerCreationPolicy.AUTO;
+
+            var properties:Object = documentDescriptor.properties;
+
+            if (properties.width != null)
+            {
+                width = properties.width;
+                delete properties.width;
+            }
+            if (properties.height != null)
+            {
+                height = properties.height;
+                delete properties.height;
+            }
+
+            // Flex auto-generated code has already set up events.
+            documentDescriptor.events = null;
+        }
+         super.initialize();
+    }
+
+    /**
+     *  @private
+     */
+    override protected function createChildren():void
+    {
+        // this is to help initialize the stage
+        width = _bounds.width;
+        height = _bounds.height;
+
+        super.createChildren();
+	}
+
+
+    /**
+     *  @private
+     */
+    override protected function commitProperties():void
+    {
+        // Create and open window.
+        if (flagForOpen && !_nativeWindow)
+        {
+            var init:NativeWindowInitOptions = new NativeWindowInitOptions();
+            init.maximizable = _maximizable;
+            init.minimizable = _minimizable;
+            init.resizable = _resizable;
+            init.type = _type;
+            init.systemChrome = _systemChrome;
+            init.transparent = _transparent;
+
+            _nativeWindow = new NativeWindow(init);
+            var sm:WindowedSystemManager = new WindowedSystemManager(this);
+            _nativeWindow.stage.addChild(sm);
+            systemManager = sm;
+
+            sm.window = this;
+
+            _nativeWindow.alwaysInFront = _alwaysInFront;
+            initManagers(sm);
+            addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
+
+            var nativeApplication:NativeApplication = NativeApplication.nativeApplication;
+            nativeApplication.addEventListener(Event.ACTIVATE, nativeApplication_activateHandler, false, 0, true);
+            nativeApplication.addEventListener(Event.DEACTIVATE, nativeApplication_deactivateHandler, false, 0, true);
+            nativeApplication.addEventListener(Event.NETWORK_CHANGE, dispatchEvent, false, 0, true);
+            _nativeWindow.addEventListener("activate", nativeWindow_activateHandler, false, 0, true);
+            _nativeWindow.addEventListener("deactivate", nativeWindow_deactivateHandler, false, 0, true);
+
+            addEventListener(Event.ENTER_FRAME, enterFrameHandler);
+
+            //'register' with WindowedSystemManager so it can cleanup when done.
+            sm.addWindow(this);
+        }
+
+        // Moved the super.commitProperites() to here to allow the Window subclass to be
+        // initialized. Part of the initialization is loading the skin of the Window subclass.
+        // At this point we can call into SkinnableComponent.commitProperties without getting
+        // a "skin was not found" error.
+        super.commitProperties();
+
+        // minimum width and height
+        if (minWidthChanged || minHeightChanged)
+        {
+            var newMinWidth:Number = minWidthChanged ? _minWidth + chromeWidth() : nativeWindow.minSize.x;
+            var newMinHeight:Number = minHeightChanged ? _minHeight + chromeHeight() : nativeWindow.minSize.y;
+
+            nativeWindow.minSize = new Point(newMinWidth, newMinHeight);
+
+            if (minWidthChanged)
+            {
+                minWidthChanged = false;
+                if (width < minWidth)
+                    width = minWidth;
+                dispatchEvent(new Event("minWidthChanged"));
+            }
+            if (minHeightChanged)
+            {
+                minHeightChanged = false;
+                if (height < minHeight)
+                    height = minHeight;
+                dispatchEvent(new Event("minHeightChanged"));
+            }
+        }
+
+        // maximum width and height
+        if (maxWidthChanged || maxHeightChanged)
+        {
+            var newMaxWidth:Number = maxWidthChanged ? _maxWidth + chromeWidth() : nativeWindow.maxSize.x;
+            var newMaxHeight:Number = maxHeightChanged ? _maxHeight + chromeHeight() : nativeWindow.maxSize.y;
+
+            nativeWindow.maxSize = new Point(newMaxWidth, newMaxHeight);
+
+            if (maxWidthChanged)
+            {
+                maxWidthChanged = false;
+                if (width > maxWidth)
+                    width = maxWidth;
+                dispatchEvent(new Event("maxWidthChanged"));
+            }
+            if (maxHeightChanged)
+            {
+                maxHeightChanged = false;
+                if (height > maxHeight)
+                    height = maxHeight;
+                dispatchEvent(new Event("maxHeightChanged"));
+            }
+        }
+
+        if (boundsChanged)
+        {
+            // We use temporary variables because when we set stageWidth or
+            // stageHeight _bounds will be overwritten when we receive
+            // a RESIZE event.
+            var newWidth:Number  = _bounds.width;
+            var newHeight:Number = _bounds.height;
+            systemManager.stage.stageWidth = newWidth;
+            systemManager.stage.stageHeight = newHeight;
+            boundsChanged = false;
+        }
+
+        if (menuChanged && !nativeWindow.closed)
+        {
+            menuChanged = false;
+
+            if (menu == null)
+            {
+                if (NativeWindow.supportsMenu)
+                    nativeWindow.menu = null;
+            }
+            else if (menu.nativeMenu)
+            {
+                if (NativeWindow.supportsMenu)
+                    nativeWindow.menu = menu.nativeMenu;
+            }
+
+            dispatchEvent(new Event("menuChanged"));
+        }
+
+        if (showTitleBarChanged)
+        {
+            if (titleBar)
+            {
+                titleBar.visible = _showTitleBar;
+                titleBar.includeInLayout = _showTitleBar;
+            }
+
+            if (titleBarBackgroundRect)
+            {
+            	titleBarBackgroundRect.visible = _showTitleBar;
+            	titleBarBackgroundRect.includeInLayout = _showTitleBar;
+            }
+
+			showTitleBarChanged = false;
+        }
+
+        if (titleIconChanged)
+        {
+            if (titleBar)
+                titleBar.titleIcon = _titleIcon;
+            titleIconChanged = false;
+        }
+
+        if (titleChanged)
+        {
+            if (!nativeWindow.closed)
+                systemManager.stage.nativeWindow.title = _title;
+            if (titleBar)
+                titleBar.title = _title;
+            titleChanged = false;
+        }
+
+        if (showStatusBarChanged)
+        {
+            if (statusBar)
+                statusBar.visible = _showStatusBar;
+            showStatusBarChanged = false;
+        }
+
+        if (statusChanged)
+        {
+            if (statusBar && "status" in statusBar)
+                statusBar["status"] = _status;
+            statusChanged = false;
+        }
+
+        if (showGripperChanged)
+        {
+            if (gripper)
+            {
+                gripper.visible = _showGripper;
+            }
+            showGripperChanged = false;
+        }
+
+        if (toMax)
+        {
+            toMax = false;
+            if (!nativeWindow.closed)
+                nativeWindow.maximize();
+        }
+
+     }
+
+
+     /**
+     *  @private
+     */
+    override public function move(x:Number, y:Number):void
+    {
+        if (nativeWindow && !nativeWindow.closed)
+        {
+            var tmp:Rectangle = nativeWindow.bounds;
+            tmp.x = x;
+            tmp.y = y;
+            nativeWindow.bounds = tmp;
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Closes the window. This action is cancelable.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function close():void
+    {
+        if (_nativeWindow && !nativeWindow.closed)
+        {
+            var e:Event = new Event("closing", false, true);
+            stage.nativeWindow.dispatchEvent(e);
+            if (!(e.isDefaultPrevented()))
+            {
+                stage.nativeWindow.close();
+                _nativeWindow = null;
+                systemManager.removeChild(this);
+            }
+        }
+    }
+
+    /**
+     *  @private
+     */
+    private function initManagers(sm:ISystemManager):void
+    {
+        if (sm.isTopLevel())
+        {
+            focusManager = new FocusManager(this);
+            sm.activate(this);
+            _cursorManager = new CursorManagerImpl(sm);
+        }
+    }
+
+    /**
+     *  Maximizes the window, or does nothing if it's already maximized.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function maximize():void
+    {
+        if (!nativeWindow || !nativeWindow.maximizable || nativeWindow.closed)
+            return;
+        if (stage.nativeWindow.displayState!= NativeWindowDisplayState.MAXIMIZED)
+        {
+            var f:NativeWindowDisplayStateEvent = new NativeWindowDisplayStateEvent(
+                        NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,
+                        false, true, stage.nativeWindow.displayState,
+                        NativeWindowDisplayState.MAXIMIZED);
+            stage.nativeWindow.dispatchEvent(f);
+            if (!f.isDefaultPrevented())
+            {
+                toMax = true;
+                invalidateProperties();
+                invalidateSize();
+            }
+        }
+    }
+
+    /**
+     *  Minimizes the window.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function minimize():void
+    {
+        if (!nativeWindow.closed)
+        {
+            var e:NativeWindowDisplayStateEvent = new NativeWindowDisplayStateEvent(
+                    NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,
+                    false, true, nativeWindow.displayState,
+                    NativeWindowDisplayState.MINIMIZED)
+            stage.nativeWindow.dispatchEvent(e);
+            if (!e.isDefaultPrevented())
+                stage.nativeWindow.minimize();
+        }
+    }
+
+    /**
+     *  Restores the window (unmaximizes it if it's maximized, or
+     *  unminimizes it if it's minimized).
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function restore():void
+    {
+        if (!nativeWindow.closed)
+        {
+            var e:NativeWindowDisplayStateEvent;
+            if (stage.nativeWindow.displayState == NativeWindowDisplayState.MAXIMIZED)
+            {
+                e = new NativeWindowDisplayStateEvent(
+                            NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,
+                            false, true, NativeWindowDisplayState.MAXIMIZED,
+                            NativeWindowDisplayState.NORMAL);
+                stage.nativeWindow.dispatchEvent(e);
+                if (!e.isDefaultPrevented())
+                    nativeWindow.restore();
+            }
+            else if (stage.nativeWindow.displayState == NativeWindowDisplayState.MINIMIZED)
+            {
+                e = new NativeWindowDisplayStateEvent(
+                    NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,
+                    false, true, NativeWindowDisplayState.MINIMIZED,
+                    NativeWindowDisplayState.NORMAL);
+                stage.nativeWindow.dispatchEvent(e);
+                if (!e.isDefaultPrevented())
+                    nativeWindow.restore();
+            }
+        }
+    }
+
+    /**
+     *  Activates the underlying NativeWindow (even if this Window's application
+     *  is not currently active).
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function activate():void
+    {
+        if (!nativeWindow.closed)
+            _nativeWindow.activate();
+    }
+
+    /**
+     *  Creates the underlying NativeWindow and opens it.
+     *
+     *  @param  openWindowActive specifies whether the Window opens
+     *  activated (that is, whether it has focus). The default value
+     *  is true.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function open(openWindowActive:Boolean = true):void
+    {
+        flagForOpen = true;
+        openActive = openWindowActive;
+        commitProperties();
+    }
+
+    /**
+     *  Orders the window just behind another. To order the window behind
+     *  a NativeWindow that does not implement IWindow, use this window's
+     *  nativeWindow's orderInBackOf() method.
+     *
+     *  @param window The IWindow (Window or WindowedAplication)
+     *  to order this window behind.
+     *
+     *  @return true if the window was succesfully sent behind;
+     *          false if the window is invisible or minimized.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function orderInBackOf(window:IWindow):Boolean
+    {
+        if (nativeWindow && !nativeWindow.closed)
+            return nativeWindow.orderInBackOf(window.nativeWindow);
+        else
+            return false;
+    }
+
+    /**
+     *  Orders the window just in front of another. To order the window
+     *  in front of a NativeWindow that does not implement IWindow, use this
+     *  window's nativeWindow's  orderInFrontOf() method.
+     *
+     *  @param window The IWindow (Window or WindowedAplication)
+     *  to order this window in front of.
+     *
+     *  @return true if the window was succesfully sent in front;
+     *          false if the window is invisible or minimized.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function orderInFrontOf(window:IWindow):Boolean
+    {
+        if (nativeWindow && !nativeWindow.closed)
+            return nativeWindow.orderInFrontOf(window.nativeWindow);
+        else
+            return false;
+    }
+
+    /**
+     *  Orders the window behind all others in the same application.
+     *
+     *  @return true if the window was succesfully sent to the back;
+     *  false if the window is invisible or minimized.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function orderToBack():Boolean
+    {
+        if (nativeWindow && !nativeWindow.closed)
+            return nativeWindow.orderToBack();
+        else
+            return false;
+    }
+
+    /**
+     *  Orders the window in front of all others in the same application.
+     *
+     *  @return true if the window was succesfully sent to the front;
+     *  false if the window is invisible or minimized.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function orderToFront():Boolean
+    {
+        if (nativeWindow && !nativeWindow.closed)
+            return nativeWindow.orderToFront();
+        else
+            return false;
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    // Skin states support
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Returns the name of the state to be applied to the skin. For example, a
+     *  Button component could return the String "up", "down", "over", or "disabled"
+     *  to specify the state.
+     *
+     *
A subclass of SkinnableComponent must override this method to return a value.

+     *
+     *  @return A string specifying the name of the state to apply to the skin.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    override protected function getCurrentSkinState():String
+    {
+
+        if (nativeWindow.closed)
+            return "disabled";
+
+        if (nativeWindow.active)
+            return enabled ? "normal" : "disabledActive";
+        else
+            return enabled ? "normalInactive" : "disabledInactive";
+
+    }
+
+    /**
+     *  @private
+     *  Returns the width of the chrome for the window
+     */
+    private function chromeWidth():Number
+    {
+        return nativeWindow.width - systemManager.stage.stageWidth;
+    }
+
+    /**
+     *  @private
+     *  Returns the height of the chrome for the window
+     */
+    private function chromeHeight():Number
+    {
+        return nativeWindow.height - systemManager.stage.stageHeight;
+    }
+
+    /**
+     *  @private
+     *  Starts a system move.
+     */
+    private function startMove(event:MouseEvent):void
+    {
+        addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
+        addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
+
+        prevX = event.stageX;
+        prevY = event.stageY;
+    }
+
+    /**
+     *  @private
+     *  Starts a system resize.
+     */
+    private function startResize(start:String):void
+    {
+        if (resizable && !nativeWindow.closed)
+            stage.nativeWindow.startResize(start);
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Event handlers
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    private function enterFrameHandler(e:Event):void
+    {
+        if (frameCounter == 2)
+        {
+            removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
+            _nativeWindow.visible = _nativeWindowVisible;
+            dispatchEvent(new AIREvent(AIREvent.WINDOW_COMPLETE));
+
+            // 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));
+            }
+
+            if (_nativeWindow.visible)
+            {
+                if (openActive)
+                    _nativeWindow.activate();
+            }
+        }
+        frameCounter++;
+    }
+
+    /**
+     *  @private
+     */
+    private function hideEffectEndHandler(event:Event):void
+    {
+        _nativeWindow.visible = false;
+
+        dispatchEvent(new FlexEvent(FlexEvent.HIDE));
+    }
+
+    /**
+     *  @private
+     */
+    private function windowMinimizeHandler(event:Event):void
+    {
+        if (!nativeWindow.closed)
+            stage.nativeWindow.minimize();
+        removeEventListener("effectEnd", windowMinimizeHandler);
+    }
+
+    /**
+     *  @private
+     */
+    private function windowUnminimizeHandler(event:Event):void
+    {
+        removeEventListener("effectEnd", windowUnminimizeHandler);
+    }
+
+    /**
+     *  @private
+     */
+    private function window_moveHandler(event:NativeWindowBoundsEvent):void
+    {
+        var newEvent:FlexNativeWindowBoundsEvent =
+            new FlexNativeWindowBoundsEvent(
+                FlexNativeWindowBoundsEvent.WINDOW_MOVE,
+                event.bubbles, event.cancelable,
+                event.beforeBounds, event.afterBounds);
+        dispatchEvent(newEvent);
+    }
+
+    /**
+     *  @private
+     */
+    private function window_displayStateChangeHandler(
+                            event:NativeWindowDisplayStateEvent):void
+    {
+        // Redispatch event .
+        dispatchEvent(event);
+
+        height = stage.stageHeight;
+        width = stage.stageWidth;
+    }
+
+    /**
+     *  @private
+     */
+    private function window_displayStateChangingHandler(
+                            event:NativeWindowDisplayStateEvent):void
+    {
+        // Redispatch event for cancellation purposes.
+        dispatchEvent(event);
+
+        if (event.isDefaultPrevented())
+            return;
+        if (event.afterDisplayState == NativeWindowDisplayState.MINIMIZED)
+        {
+            if (getStyle("minimizeEffect"))
+            {
+                event.preventDefault();
+                addEventListener("effectEnd", windowMinimizeHandler);
+                dispatchEvent(new Event("windowMinimize"));
+            }
+        }
+
+        // After here, afterState is normal
+        else if (event.beforeDisplayState == NativeWindowDisplayState.MINIMIZED)
+        {
+            addEventListener("effectEnd", windowUnminimizeHandler);
+            dispatchEvent(new Event("windowUnminimize"));
+        }
+    }
+
+    /**
+     *  @private
+     */
+    private function windowMaximizeHandler(event:Event):void
+    {
+        removeEventListener("effectEnd", windowMaximizeHandler);
+        if (!nativeWindow.closed)
+            stage.nativeWindow.maximize();
+    }
+
+    /**
+     *  @private
+     */
+    private function windowUnmaximizeHandler(event:Event):void
+    {
+        removeEventListener("effectEnd", windowUnmaximizeHandler);
+        if (!nativeWindow.closed)
+            stage.nativeWindow.restore();
+    }
+
+    /**
+     *  Manages mouse down events on the window border.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    protected function mouseDownHandler(event:MouseEvent):void
+    {
+        if (systemManager.stage.nativeWindow.systemChrome != "none")
+            return;
+        if (event.target == gripper)
+        {
+            startResize(NativeWindowResize.BOTTOM_RIGHT);
+            event.stopPropagation();
+        }
+        else
+        {
+            var edgeOrCorner:String = hitTestResizeEdge(event);
+            if (edgeOrCorner != NativeWindowResize.NONE)
+            {
+                startResize(edgeOrCorner);
+                event.stopPropagation();
+            }
+        }
+    }
+
+    /**
+     *  @private
+     */
+    private function closeButton_clickHandler(event:Event):void
+    {
+        if (!nativeWindow.closed)
+            stage.nativeWindow.close();
+    }
+
+    /**
+     *  @private
+     *  Triggered by a resize event of the stage.
+     *  Sets the new width and height.
+     *  After the SystemManager performs its function,
+     *  it is only necessary to notify the children of the change.
+     */
+    private function resizeHandler(event:Event):void
+    {
+        // When user has not specified any width/height,
+        // application assumes the size of the stage.
+        // If developer has specified width/height,
+        // the application will not resize.
+        // If developer has specified percent width/height,
+        // application will resize to the required value
+        // based on the current stage width/height.
+        // If developer has specified min/max values,
+        // then application will not resize beyond those values.
+
+        var w:Number;
+        var h:Number
+
+        if (resizeWidth)
+        {
+            if (isNaN(percentWidth))
+            {
+                w = DisplayObject(systemManager).width;
+            }
+            else
+            {
+                super.percentWidth = Math.max(percentWidth, 0);
+                super.percentWidth = Math.min(percentWidth, 100);
+                w = percentWidth*screen.width/100;
+            }
+
+            if (!isNaN(explicitMaxWidth))
+                w = Math.min(w, explicitMaxWidth);
+
+            if (!isNaN(explicitMinWidth))
+                w = Math.max(w, explicitMinWidth);
+        }
+        else
+        {
+            w = width;
+        }
+
+        if (resizeHeight)
+        {
+            if (isNaN(percentHeight))
+            {
+                h = DisplayObject(systemManager).height;
+            }
+            else
+            {
+                super.percentHeight = Math.max(percentHeight, 0);
+                super.percentHeight = Math.min(percentHeight, 100);
+                h = percentHeight*screen.height/100;
+            }
+
+            if (!isNaN(explicitMaxHeight))
+                h = Math.min(h, explicitMaxHeight);
+
+            if (!isNaN(explicitMinHeight))
+                h = Math.max(h, explicitMinHeight);
+        }
+        else
+        {
+            h = height;
+        }
+
+        if (w != width || h != height)
+        {
+            invalidateProperties();
+            invalidateSize();
+        }
+
+        setActualSize(w, h);
+
+        invalidateDisplayList();
+    }
+
+    /**
+     *   @private
+     *
+     *   Perform a hit test to determine if an edge or corner of the application
+     *   was clicked.
+     *
+     *   @param event The mouse event to hit test.
+     *
+     *   @return If an edge or corner was click return one of the constants from
+     *   the NativeWindowResize to indicate the edit or corner that was clicked. If
+     *   no edge or corner were clicked then return NativeWindowResize.NONE.
+     */
+    private function hitTestResizeEdge(event:MouseEvent):String
+    {
+        // If we clicked on a child of the contentGroup, then don't resize
+        if (event.target is DisplayObject && event.target != contentGroup)
+        {
+           var o:DisplayObject = DisplayObject(event.target);
+            while (o != contentGroup && o != this)
+                o = o.parent;
+
+            if (o == contentGroup)
+                return NativeWindowResize.NONE;
+        }
+
+        var hitTestResults:String = NativeWindowResize.NONE;
+        var borderWidth:int = resizeAffordance;
+        var cornerSize:int = resizeAffordance * 2;
+
+        if (event.stageY < borderWidth)
+        {
+            if (event.stageX < cornerSize)
+                hitTestResults = NativeWindowResize.TOP_LEFT;
+            else if (event.stageX > width - cornerSize)
+                hitTestResults = NativeWindowResize.TOP_RIGHT;
+            else
+                hitTestResults = NativeWindowResize.TOP;
+        }
+        else if (event.stageY > (height - borderWidth))
+        {
+            if (event.stageX < cornerSize)
+                hitTestResults = NativeWindowResize.BOTTOM_LEFT;
+            else if (event.stageX > width - cornerSize)
+                hitTestResults = NativeWindowResize.BOTTOM_RIGHT;
+            else
+                hitTestResults = NativeWindowResize.BOTTOM;
+        }
+        else if (event.stageX < borderWidth )
+        {
+            if (event.stageY < cornerSize)
+                hitTestResults = NativeWindowResize.TOP_LEFT;
+            else if (event.stageY > height - cornerSize)
+                hitTestResults = NativeWindowResize.BOTTOM_LEFT;
+            else
+                hitTestResults = NativeWindowResize.LEFT;
+        }
+        else if (event.stageX > width - borderWidth)
+        {
+            if (event.stageY < cornerSize)
+                hitTestResults = NativeWindowResize.TOP_RIGHT;
+            else if (event.stageY > height - cornerSize)
+                hitTestResults = NativeWindowResize.BOTTOM_RIGHT;
+            else
+                hitTestResults = NativeWindowResize.RIGHT;
+        }
+
+        return hitTestResults;
+    }
+
+    /**
+     *  @private
+     */
+    private function creationCompleteHandler(event:Event = null):void
+    {
+        systemManager.stage.nativeWindow.addEventListener(
+            "closing", window_closingHandler);
+
+        systemManager.stage.nativeWindow.addEventListener(
+            "close", window_closeHandler, false, 0, true);
+
+        systemManager.stage.nativeWindow.addEventListener(
+            NativeWindowBoundsEvent.MOVING, window_boundsHandler);
+
+        systemManager.stage.nativeWindow.addEventListener(
+            NativeWindowBoundsEvent.MOVE, window_moveHandler);
+
+        systemManager.stage.nativeWindow.addEventListener(
+            NativeWindowBoundsEvent.RESIZING, window_boundsHandler);
+
+        systemManager.stage.nativeWindow.addEventListener(
+           NativeWindowBoundsEvent.RESIZE, window_resizeHandler);
+
+    }
+
+    /**
+     *  @private
+     */
+    private function preinitializeHandler(event:FlexEvent):void
+    {
+        systemManager.stage.nativeWindow.addEventListener(
+            NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,
+            window_displayStateChangingHandler);
+        systemManager.stage.nativeWindow.addEventListener(
+            NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE,
+            window_displayStateChangeHandler);
+    }
+
+    /**
+     *  @private
+     */
+    private function mouseMoveHandler(event:MouseEvent):void
+    {
+        stage.nativeWindow.x += event.stageX - prevX;
+        stage.nativeWindow.y += event.stageY - prevY;
+    }
+
+    /**
+     *  @private
+     */
+    private function mouseUpHandler(event:MouseEvent):void
+    {
+        removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
+        removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
+    }
+
+    /**
+     *  @private
+     */
+    private function window_boundsHandler(event:NativeWindowBoundsEvent):void
+    {
+
+        var newBounds:Rectangle = event.afterBounds;
+        var r:Rectangle;
+        if (event.type == NativeWindowBoundsEvent.MOVING)
+        {
+            dispatchEvent(event);
+            if (event.isDefaultPrevented())
+                return;
+        }
+        else //event is resizing
+        {
+            dispatchEvent(event);
+            if (event.isDefaultPrevented())
+                return;
+            var cancel:Boolean = false;
+            if (newBounds.width < nativeWindow.minSize.x)
+            {
+                cancel = true;
+                if (newBounds.x != event.beforeBounds.x && !isNaN(oldX))
+                    newBounds.x = oldX;
+                newBounds.width = nativeWindow.minSize.x;
+            }
+            else if (newBounds.width > nativeWindow.maxSize.x)
+            {
+                cancel = true;
+                if (newBounds.x != event.beforeBounds.x && !isNaN(oldX))
+                    newBounds.x = oldX;
+                newBounds.width = nativeWindow.maxSize.x;
+            }
+            if (newBounds.height < nativeWindow.minSize.y)
+            {
+                cancel = true;
+                if (event.afterBounds.y != event.beforeBounds.y && !isNaN(oldY))
+                    newBounds.y = oldY;
+                newBounds.height = nativeWindow.minSize.y;
+            }
+            else if (newBounds.height > nativeWindow.maxSize.y)
+            {
+                cancel = true;
+                if (event.afterBounds.y != event.beforeBounds.y && !isNaN(oldY))
+                    newBounds.y = oldY;
+                newBounds.height = nativeWindow.maxSize.y;
+            }
+            if (cancel)
+            {
+                event.preventDefault();
+                stage.nativeWindow.bounds = newBounds;
+            }
+        }
+        oldX = newBounds.x;
+        oldY = newBounds.y;
+    }
+
+    /**
+     *  @private
+     */
+    private function window_closeEffectEndHandler(event:Event):void
+    {
+        removeEventListener("effectEnd", window_closeEffectEndHandler);
+        if (!nativeWindow.closed)
+            stage.nativeWindow.close();
+    }
+
+    /**
+     *  @private
+     */
+    private function window_closingHandler(event:Event):void
+    {
+        var e:Event = new Event("closing", true, true);
+        dispatchEvent(e);
+        if (e.isDefaultPrevented())
+        {
+            event.preventDefault();
+        }
+        else if (getStyle("closeEffect") &&
+                 stage.nativeWindow.transparent == true)
+        {
+            addEventListener("effectEnd", window_closeEffectEndHandler);
+            dispatchEvent(new Event("windowClose"));
+            event.preventDefault();
+        }
+    }
+
+    /**
+     *  @private
+     */
+    private function window_closeHandler(event:Event):void
+    {
+        dispatchEvent(new Event("close"));
+
+        // Event for Automation so we know when windows
+        // are created or destroyed.
+        if (FlexGlobals.topLevelApplication)
+        {
+            FlexGlobals.topLevelApplication.dispatchEvent(
+                new WindowExistenceEvent(WindowExistenceEvent.WINDOW_CLOSE,
+                                         false, false, this));
+        }
+    }
+
+    /**
+     *  @private
+     */
+    private function window_resizeHandler(event:NativeWindowBoundsEvent):void
+    {
+        invalidateDisplayList();
+
+        var dispatchWidthChangeEvent:Boolean = (bounds.width != stage.stageWidth);
+        var dispatchHeightChangeEvent:Boolean = (bounds.height != stage.stageHeight);
+
+        bounds.x = stage.x;
+        bounds.y = stage.y;
+        bounds.width = stage.stageWidth;
+        bounds.height = stage.stageHeight;
+
+        validateNow();
+        var e:FlexNativeWindowBoundsEvent =
+            new FlexNativeWindowBoundsEvent(FlexNativeWindowBoundsEvent.WINDOW_RESIZE, event.bubbles, event.cancelable,
+                    event.beforeBounds, event.afterBounds);
+        dispatchEvent(e);
+
+        if (dispatchWidthChangeEvent)
+            dispatchEvent(new Event("widthChanged"));
+        if (dispatchHeightChangeEvent)
+            dispatchEvent(new Event("heightChanged"));
+    }
+
+    /**
+     *  @private
+     */
+    private function nativeApplication_activateHandler(event:Event):void
+    {
+        dispatchEvent(new AIREvent(AIREvent.APPLICATION_ACTIVATE));
+    }
+
+    /**
+     *  @private
+     */
+    private function nativeApplication_deactivateHandler(event:Event):void
+    {
+        dispatchEvent(new AIREvent(AIREvent.APPLICATION_DEACTIVATE));
+    }
+
+    /**
+     *  @private
+     */
+    private function nativeWindow_activateHandler(event:Event):void
+    {
+        dispatchEvent(new AIREvent(AIREvent.WINDOW_ACTIVATE));
+        invalidateSkinState();
+    }
+
+    /**
+     *  @private
+     */
+    private function nativeWindow_deactivateHandler(event:Event):void
+    {
+        dispatchEvent(new AIREvent(AIREvent.WINDOW_DEACTIVATE));
+        invalidateSkinState();
+    }
+
+}
+
+}


Transferred from the Adobe Open Source Subversion Repository

Revision: 2644
Author:   egeorgie@adobe.com
Date:     2008-07-28T23:58:09.872940Z

Log Message:
-----------
First pass at unifying layout APIs between UIComponent and GraphicElement, more to come with additional check-ins.

reviewed by Ryan, Glenn, Gordon, Chet

Modified Paths:
--------------
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/Path.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/Ellipse.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/Rect.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/TextBox.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/IGraphicElement.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/TextGraphic.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/core/Group.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/StrokedElement.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/graphicsClasses/GraphicElement.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/Line.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/FilledElement.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/core/UIComponent.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/BitmapGraphic.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/graphics/graphicsClasses/TextGraphicElement.as</path>

git-svn-id: 7146a936b37d36e51ea0d66f8acbe0b8281bc7b7@1283206 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/spark/src/spark/core/IGraphicElement.as
+++ frameworks/projects/spark/src/spark/core/IGraphicElement.as
@@ -193,13 +193,6 @@
     //
     //--------------------------------------------------------------------------

-    /**
-     *  Draws the element.
-     *
-     *  @param g The graphics context where the element is drawn.
-     */
-	function draw(g:Graphics):void;
-
 	function applyMask():void;
 }
 }


added check for null

added check for null

--- WeaveJS/src/weavejs/data/column/ReferencedColumn.as
+++ WeaveJS/src/weavejs/data/column/ReferencedColumn.as
@@ -107,8 +107,10 @@
 		public static function generateReferencedColumnStateFromColumnReference(ref:IColumnReference):Object
 		{
 			var dataSource:IDataSource = ref.getDataSource();
+			var root:ILinkableHashMap = Weave.getRoot(dataSource);
+			var name:String = root ? root.getName(dataSource) : null;
 			return {
-				"dataSourceName": Weave.getRoot(dataSource).getName(dataSource),
+				"dataSourceName": name,
 				"metadata": ref.getColumnMetadata()
 			};
 		}


Code and comment cleanup

Code and comment cleanup

--- airServerDemo/src/ServerGame.as
+++ airServerDemo/src/ServerGame.as
@@ -97,18 +97,18 @@
 		/**
 		* Called by the server binary when a connection comes in.
 		*/
-		public function onConnection(s:Socket):void
+		public function onConnection(clientSocket:Socket):void
 		{
 			// Set up the connection, and add it to the list.
-			var ec:GhostConnection = new GhostConnection();
-			ec.activateGhosting(true);
-			ec.scopeObject = this;
-			ec.acceptClientConnection(s, null, 0);
+			var connection:GhostConnection = new GhostConnection();
+			connection.activateGhosting(true);
+			connection.scopeObject = this;
+			connection.acceptClientConnection(clientSocket, null, 0);

 			// Send a welcome message.
-			ec.postEvent(new ChatEvent("Welcome to Circle Click: Multiplayer Edition!"));
+			connection.postEvent(new ChatEvent("Welcome to Circle Click: Multiplayer Edition!"));

-			ec.sendPacket();
+			connection.sendPacket();
 		}

 		/**


R IExternalizable and custom classes for the sake of interoperability

git-svn-id: 3704838867447408e01268abee7e32a5bd8c3d03@10 5cda2b45-c24c-6f34-eaa9-e0910a1cbe04

--- src/aerys/qark/Qark.as
+++ src/aerys/qark/Qark.as
@@ -9,16 +9,16 @@

 	public class Qark
 	{
-		private static const FLAG_CUSTOM		: int		= 0;
-		private static const FLAG_OBJECT		: int		= 1;
-		private static const FLAG_ARRAY			: int		= 2;
-		private static const FLAG_INTEGER		: int		= 3;
-		private static const FLAG_FLOAT			: int		= 4;
-		private static const FLAG_STRING		: int		= 5;
-		private static const FLAG_UTF_STRING	: int		= 6;
-		private static const FLAG_BYTES			: int		= 7;
-		private static const FLAG_BOOLEAN		: int		= 8;
-		private static const FLAG_BITMAP_DATA	: int		= 9;
+		private static const FLAG_CUSTOM		: int	= 0;
+		private static const FLAG_OBJECT		: int	= 1;
+		private static const FLAG_ARRAY			: int	= 2;
+		private static const FLAG_INTEGER		: int	= 3;
+		private static const FLAG_FLOAT			: int	= 4;
+		private static const FLAG_STRING		: int	= 5;
+		private static const FLAG_UTF_STRING	: int	= 6;
+		private static const FLAG_BYTES			: int	= 7;
+		private static const FLAG_BOOLEAN		: int	= 8;
+		private static const FLAG_BITMAP_DATA	: int	= 9;

 		private static const ENCODERS		: Array		= [encodeCustomObject,
@@ -229,39 +229,22 @@

 		private static function encodeCustomObject(source : Object, target : ByteArray) : void
 		{
-			if (source is IExternalizable)
+			var variables	: XMLList = describeType(source).variable;
+			var object		: Object = new Object();
+
+			for each (var variable : XML in variables)
 			{
-				(source as IExternalizable).writeExternal(target);
+				var propertyName : String = variable.@name;
+
+				object[propertyName] = source[propertyName];
 			}
-			else
-			{
-				var variables : XMLList = describeType(source).variable;
-				var object	: Object = new Object();
-
-				encodeString(getQualifiedClassName(source), target);
-
-				for each (var variable : XML in variables)
-				{
-					var propertyName : String = variable.@name;
-
-					object[propertyName] = source[propertyName];
-				}
-
-				encodeObject(object, target);
-			}
+
+			encodeObject(object, target);
 		}

 		private static function decodeCustomObject(source : ByteArray) : Object
 		{
-			var className : String = decodeString(source);
-			var instance : Object = new (getDefinitionByName(className))();
-
-			if (instance is IExternalizable)
-				(instance as IExternalizable).readExternal(source);
-			else
-				decodeObject(source, instance);
-
-			return instance;
+			return decodeObject(source);
 		}

 		private static function encodeBitmapData(source : BitmapData, target : ByteArray) : void