(AIR only)
Packageflash.display
Classpublic class NativeWindow
InheritanceNativeWindow Inheritance EventDispatcher Inheritance Object

The NativeWindow class provides an interface for creating and controlling native desktop windows.

A reference to the NativeWindow is returned by the window constructor. A reference to a NativeWindow instance can also be accessed using the stage.nativeWindow property of any display object on that window's stage:

var window:NativeWindow = displayObject.stage.nativeWindow;

The properties of a NativeWindow instance can only be accessed by application content. If non-application content attempts to access the NativeWindow, a security error will be thrown.

Content can be added to the stage of a window using the DisplayObjectContainer APIs such as addChild().

You should not add Flex components directly to the display list of a NativeWindow instance. Instead, use the Flex mx:WindowedApplication and mx:Window components to create your windows and add the other Flex components as children to those objects. You can add a loaded Flex-based SWF directly to a NativeWindow window as long as that SWF is loaded into its own application domain and is application content.

To create a root HTML window for displaying HTML content it is typically easier to create the window with HTMLLoader.createRootContent(). Windows created in this way will have an HTMLLoader added automatically as well as scrollbar support.(From JavaScript code, you can also use the JavaScript window.open() function, although this method gives less control over the window chrome.)

The following operations on NativeWindows are asynchronous: close(), maximize(), minimize(), restore(), and bounds changes. An application can detect when these operations have completed by listening for the appropriate events.

If the NativeApplication.autoExit property is true, which is the default, the application will close when it's last window is closed (and all close event handlers have returned). If autoExit is false, then NativeApplication.nativeApplication.exit() must be called to terminate the application.

NativeWindow objects will not be garbage collected after the window constructor has been called and before close() has been called. It is the responsibility of the application to close its own windows.

See also

flash.display.Stage.nativeWindow
flash.display.NativeWindowInitOptions
flash.desktop.NativeApplication
flash.system.ApplicationDomain
flash.html.HTMLLoader.createRootWindow()


Public Properties
 PropertyDefined By
  AIR-onlyactive : Boolean
[read-only] Indicates whether this window is the active application window.
NativeWindow
  AIR-onlyalwaysInFront : Boolean
Specifies whether this window will always be in front of other windows (including those of other applications).
NativeWindow
  AIR-onlybounds : Rectangle
The size and location of this window.
NativeWindow
  AIR-onlyclosed : Boolean
[read-only] Indicates whether this window has been closed.
NativeWindow
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  AIR-onlydisplayState : String
[read-only] A string reporting this window's current display state.
NativeWindow
  AIR-onlyheight : Number
The height of this window in pixels.
NativeWindow
  AIR-onlymaximizable : Boolean
[read-only] Reports the maximizable setting used to create this window.
NativeWindow
  AIR-onlymaxSize : Point
The maximum size for this window.
NativeWindow
  AIR-onlymenu : NativeMenu
The native menu for this window.
NativeWindow
  AIR-onlyminimizable : Boolean
[read-only] Reports the minimizable setting used to create this window.
NativeWindow
  AIR-onlyminSize : Point
The minimum size for this window.
NativeWindow
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  AIR-onlyresizable : Boolean
[read-only] Reports the resizable setting used to create this window.
NativeWindow
  AIR-onlystage : Stage
[read-only] The Stage object for this window.
NativeWindow
  AIR-onlysupportsMenu : Boolean
[static] [read-only] Indicates whether AIR supports native window menus on the current computer system.
NativeWindow
  AIR-onlysupportsNotification : Boolean
[static] [read-only] Indicates whether AIR supports window notification cueing on the current computer system.
NativeWindow
  AIR-only supportsTransparency : Boolean
[static] [read-only] Indicates whether AIR supports native windows with transparent pixels.
NativeWindow
  AIR-onlysystemChrome : String
[read-only] Reports the system chrome setting used to create this window.
NativeWindow
  AIR-onlysystemMaxSize : Point
[static] [read-only] The largest window size allowed by the operating system.
NativeWindow
  AIR-onlysystemMinSize : Point
[static] [read-only] The smallest window size allowed by the operating system.
NativeWindow
  AIR-onlytitle : String
The window title.
NativeWindow
  AIR-onlytransparent : Boolean
[read-only] Reports the transparency setting used to create this window.
NativeWindow
  AIR-onlytype : String
[read-only] Reports the window type setting used to create this window.
NativeWindow
  AIR-onlyvisible : Boolean
Specifies whether this window is visible.
NativeWindow
  AIR-onlywidth : Number
The width of this window in pixels.
NativeWindow
  AIR-onlyx : Number
The horizontal axis coordinate of this window's top left corner relative to the upper left corner of the operating system's desktop.
NativeWindow
  AIR-onlyy : Number
The vertical axis coordinate of this window's top left corner relative to the upper left corner of the operating system's desktop.
NativeWindow
Public Methods
 MethodDefined By
  
Creates a new NativeWindow instance and a corresponding operating system window.
NativeWindow
  
AIR-onlyactivate():void
Activates this window.
NativeWindow
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
  
AIR-onlyclose():void
Closes this window.
NativeWindow
 Inherited
Dispatches an event into the event flow.
EventDispatcher
  
AIR-onlyglobalToScreen(globalPoint:Point):Point
Converts a point in pixel coordinates relative to the origin of the window stage (a global point in terms of the display list), to a point on the virtual desktop.
NativeWindow
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
AIR-onlymaximize():void
Maximizes this native window according to system rules and behavior.
NativeWindow
  
AIR-onlyminimize():void
Minimizes this native window according to system rules and behavior.
NativeWindow
  
Triggers a visual cue through the operating system that an event of interest has occured.
NativeWindow
  
Sends this window directly behind the specified window. Does not activate or acquire the focus for the window or the application.
NativeWindow
  
Brings this window directly in front of the specified window. Does not activate or acquire the focus for the window or the application.
NativeWindow
  
Sends this window behind any other visible windows. Does not activate or acquire the focus for this window or the application.
NativeWindow
  
Brings this window in front of any other visible windows.
NativeWindow
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
  
AIR-onlyrestore():void
Restores this window from either a minimized or a maximized state.
NativeWindow
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
  
Starts a system-controlled move of this window.
NativeWindow
  
AIR-onlystartResize(edgeOrCorner:String):Boolean
Starts a system-controlled resize operation of this window.
NativeWindow
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Events
 Event Summary Defined By
   Dispatched by this NativeWindow object after the window has been activated.NativeWindow
  
AIR-onlyclose
Dispatched by this NativeWindow object after the window has been closed.NativeWindow
  
AIR-onlyclosing
Dispatched by this NativeWindow object immediately before the window is to be closed.NativeWindow
   Dispatched by this NativeWindow object after the window has been deactivated.NativeWindow
   Dispatched by this NativeWindow object after the window's displayState has changed.NativeWindow
   Dispatched by this NativeWindow object immediately before the window changes displayState.NativeWindow
  
AIR-onlymove
Dispatched by this NativeWindow object after the window has been moved on the desktop.NativeWindow
  
AIR-onlymoving
Dispatched by the NativeWindow object immediately before the window is to be moved on the desktop.NativeWindow
  
AIR-onlyresize
Dispatched by this NativeWindow object after the window has been resized.NativeWindow
   Dispatched by this NativeWindow object immediately before the window is to be resized on the desktop.NativeWindow
Property Detail
AIR-only activeproperty
active:Boolean  [read-only]

Indicates whether this window is the active application window.

Use the activate() method to make a window active.


Implementation
    public function get active():Boolean

See also

AIR-only alwaysInFrontproperty 
alwaysInFront:Boolean  [read-write]

Specifies whether this window will always be in front of other windows (including those of other applications).

There are two groups of windows in the system depth order. Windows in the alwaysInFront=true group are always displayed in front of all other windows. Depth ordering between windows within the same group is determined normally. In other words, activating a window will bring it in front of other windows in its group.

Changing alwaysInFront from false to true will bring the window to the top of all other windows. Changing the property from true to false will send the window to the back of "alwaysInFront" windows, but still in front of other windows. Setting the property to its current value will not change the window depth order.

alwaysInFront=true should be used sparingly since windows with this setting will appear in front of the windows of other applications even when the other application is active.

Note: On Mac OS X, setting alwaysInFront=true will have no effect when the displayState property of the window stage is fullScreen or fullScreenInteractive.


Implementation
    public function get alwaysInFront():Boolean
    public function set alwaysInFront(value:Boolean):void

Example

The following example forces a window to be displayed in front of all other windows (that are not similarly forced to the front):
windowObj.alwaysInFront = true;

With a reference to display object on the window stage:
displayObject.stage.nativeWindow.alwaysToFront=true;

From a JavaScript routine running in an HTMLLoader in the window (or a root HTML window):
window.nativeWindow.alwaysInFront = true;
AIR-only boundsproperty 
bounds:Rectangle  [read-write]

The size and location of this window.

The dimensions of a window include any system chrome. The dimensions of a window's stage are equal to the dimensions of the window, minus the size of any system chrome. Changing the width and height of the window will change the stage's stageWidth and stageHeight. The reverse also applies; changing the stage dimensions will change the window size.

In a root HTML window, the outerWidth and outerHeigth properties are equivalent to the window height and width. The innerWidth and innerHeight properties equal the stage.stageWidth and stage.stageHeight properties minus the thickness of any automatic scrollbars displayed by the window.

A NativeWindowBoundsChangeEvent "resize" event is dispatched whenever the width or height of this window changes. Likewise, a "move" event is dispatched whenever the origin (x,y) of this window changes. Setting the bounds property directly will not dispatch a "moving" or "resizing" event. To allow other components to prepare for or cancel an impending move or resize operation, your bounds changing logic can dispatch "moving" and "resizing" events with the NativeWindow.dispatchEvent method and then check whether the event was cancelled by a registered listener.

Setting the bounds property of a window is equivalent to setting its x, y, width, and height properties (and vice-versa).

If the width and the height specified are less than the minimum or greater than the maximum allowed size, either because of the minSize and maxSize properties of the window, or the minimum and maximum operating system limits, then the window dimensions are set to the closest legal size. The minimum width and height of any displayed system chrome may also result in a window that is larger than the specified size.


Implementation
    public function get bounds():Rectangle
    public function set bounds(value:Rectangle):void

Throws
ArgumentError — if the rectangle is null or contains invalid values.
 
IllegalOperationError — if the bounds property is accessed after this window has been closed.

See also


Example

The following example sets the bounds of a window using a reference to the native window:
windowObj.bounds = new Rectangle(200,200,1000,800);

With a reference to a display object on the window stage:
displayObject.stage.nativeWindow.bounds = new Rectangle(20,20,800,600);

From a JavaScript routine running in an HTMLLoader in the window (or a root HTML window):
window.nativeWindow.bounds = new air.Rectangle(20,20,800,600);
AIR-only closedproperty 
closed:Boolean  [read-only]

Indicates whether this window has been closed.

Accessing the following properties on a closed window will throw an IllegalOperationError:

Likewise, calling the following methods on a closed window will also throw an IllegalOperationError:


Implementation
    public function get closed():Boolean

Example

The following example shows how to access the closed property of a window:
var isWindowClosed:Boolean = windowObj.closed;

With a reference to a display object on the window stage:
var isWindowClosed:Boolean = displayObject.stage.nativeWindow.closed;

From a JavaScript routine running in an HTMLLoader in the window (or root HTML window):
var isWindowClosed = window.nativeWindow.closed;
AIR-only displayStateproperty 
displayState:String  [read-only]

A string reporting this window's current display state.

Constants for the possible values are defined in the NativeWindowDisplayState class:


Implementation
    public function get displayState():String

Throws
IllegalOperationError — if the displayState is read after this window has been closed.

See also


Example

The following example shows how to get the current window display state given a reference to the window object:
var state:String = windowObj.displayState;
AIR-only heightproperty 
height:Number  [read-write]

The height of this window in pixels.

The dimensions of a window include any system window chrome that is displayed. The height of the usable display area inside a window is available from the Stage.stageHeight property.

Changing the height property of a window is equivalent to changing the height through the bounds property.

If the height specified is less than the minimum or greater than the maximum allowed height, either because of the minSize and maxSize properties of the window, or the minimum and maximum operating system limits, then the window height is set to the closest legal size.


Implementation
    public function get height():Number
    public function set height(value:Number):void

Throws
ArgumentError — if the value set is null or invalid.
 
IllegalOperationError — if the property is accessed after this window has been closed.

See also

AIR-only maximizableproperty 
maximizable:Boolean  [read-only]

Reports the maximizable setting used to create this window.

The maximizable setting cannot be changed after a window is created.


Implementation
    public function get maximizable():Boolean

Throws
SecurityError — When trying to set to false without sufficient privilege.
 
IllegalOperationError — if the property is accessed after this window has been closed.

See also

AIR-only maxSizeproperty 
maxSize:Point  [read-write]

The maximum size for this window.

The size limit is specified as the coordinates of a Point object. Point.x corresponds to the window width; Point.y to the window height.

maxSize is enforced for window resizing operations invoked both through ActionScript code and through the operating system.

Setting maxSize, will change the window bounds if the current bounds are larger than the new maximum size.

Note: Maximizing a window will only enlarge the window to the maxSize value even if the maximized window will be smaller than the operating system screen. The window will still be in the maximized display state.


Implementation
    public function get maxSize():Point
    public function set maxSize(value:Point):void

Throws
IllegalOperationError — if assigned size is not within the operating system minimum and maximum window sizes.
 
SecurityError — if size is forbidden for the content's current privilege.
 
ArgumentError — if the size is null or contains invalid values.
 
IllegalOperationError — if the maxSize property is accessed after this window has been closed.

See also


Example

The following examples show how to set the maximum allowed size for a window.
windowObj.maxSize = new Point(1040,920);

With a reference to a display object on the window stage:
displayObject.stage.nativeWindow.maxSize = new Point(800,600);

From a JavaScript routine running in an HTMLLoader in a window (or in a root HTML window):
window.nativeWindow.maxSize = new air.Point(960,960);
AIR-only menuproperty 
menu:NativeMenu  [read-write]

The native menu for this window.

When a NativeMenu object is assigned to the window menu property, a native menu will be displayed for a window if NativeWindow.supportsMenu is true, unless the window systemChrome property is NativeWindowSystemChrome.NONE.

Note: Assigning a menu to a window when NativeWindow.supportsMenu is false or when the window systemChrome property is NativeWindowSystemChrome.NONE is allowed, but does nothing.


Implementation
    public function get menu():NativeMenu
    public function set menu(value:NativeMenu):void

See also

AIR-only minimizableproperty 
minimizable:Boolean  [read-only]

Reports the minimizable setting used to create this window.

The minimizable setting cannot be changed after a window is created.


Implementation
    public function get minimizable():Boolean

Throws
SecurityError — When trying to set to false without sufficient privilege.
 
IllegalOperationError — if the property is accessed after this window has been closed.

See also

AIR-only minSizeproperty 
minSize:Point  [read-write]

The minimum size for this window.

The size limit is specified as the coordinates of a Point object. Point.x corresponds to the window width; Point.y to the window height.

Setting minSize, will change the window bounds if the current bounds are smaller than the new minimum size.

minSize is enforced for window resizing operations invoked both through ActionScript code and through the operating system.

Note: The width and height of any displayed system chrome may make it impossible to set a window as small as the specified minimum size.


Implementation
    public function get minSize():Point
    public function set minSize(value:Point):void

Throws
IllegalOperationError — if the assigned size is not within the operating system minimum and maximum window sizes.
 
SecurityError — if size is forbidden for the content's current privilege.
 
ArgumentError — if the size is null or contains invalid values.
 
IllegalOperationError — if the minSize property is accessed after this window has been closed.

See also


Example

The following examples show how to set the minimum allowed size for a window.
windowObj.minSize = new Point(200,80);

With a reference to a display object on the window stage:
displayObject.stage.nativeWindow.minSize = new Point(120,60);

From a JavaScript routine running in an HTMLLoader in a window (or in a root HTML window):
window.nativeWindow.minSize = new air.Point(80,60);
AIR-only resizableproperty 
resizable:Boolean  [read-only]

Reports the resizable setting used to create this window.

The resizable setting cannot be changed after a window is created.


Implementation
    public function get resizable():Boolean

Throws
SecurityError — When trying to set to false without sufficient privilege.
 
IllegalOperationError — if the property is accessed after this window has been closed.

See also

AIR-only stageproperty 
stage:Stage  [read-only]

The Stage object for this window. The Stage object is the root object in the display list architecture used in ActionScript 3.0-based SWF content.

The stage is the root of the display list for the window. Add visual display objects to a window by adding them to the stage or to another object already in the display list of this stage. The stage dimensions are that of the window client area when the window uses system chrome. The stage dimensions are equal to the dimensions of the window if system chrome is not used.


Implementation
    public function get stage():Stage

See also


Example

The following example shows how to set stage properties for a NativeWindow instance:
import flash.display.StageAlign;

windowObj.stage.align = StageAlign.TOP_LEFT;
AIR-only supportsMenuproperty 
supportsMenu:Boolean  [read-only]

Indicates whether AIR supports native window menus on the current computer system.

When NativeWindow.supportsMenu is true, then a native menu will be displayed for a window when a NativeMenu object is assigned to the window menu property, unless the window systemChrome property is NativeWindowSystemChrome.NONE.

Note: Assigning a menu to a window when NativeWindow.supportsMenu is false or when the window systemChrome property is NativeWindowSystemChrome.NONE is allowed, but does nothing.


Implementation
    public static function get supportsMenu():Boolean

See also

AIR-only supportsNotificationproperty 
supportsNotification:Boolean  [read-only]

Indicates whether AIR supports window notification cueing on the current computer system.

When NativeWindow.supportsNotification is true, then calling the window's notify() method will result in a visual cue to the user that an event of interest has occured. This visual cue will conform to the operating system convention of the native system. For example, on Windows, the task bar icon will flash.

Note: Calling notify() when NativeWindow.supportsNotification is false is allowed, but does nothing.


Implementation
    public static function get supportsNotification():Boolean

See also

AIR-only supportsTransparencyproperty 
supportsTransparency:Boolean  [read-only]

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.1

Indicates whether AIR supports native windows with transparent pixels.

When NativeWindow.supportsTransparency is true, transparency in pixels of a native window will be honored, if the window transparent property is set to true. Opacity of all pixels will be set to 1 if NativeWindow.supportsTransparency is false, regardless of the value of the window transparent property. Fully transparent pixels will render as black when NativeWindow.supportsTransparency is false.

Note: The value of this property might change while an appliction is running, based on user preferences.


Implementation
    public static function get supportsTransparency():Boolean

See also

AIR-only systemChromeproperty 
systemChrome:String  [read-only]

Reports the system chrome setting used to create this window.

The values returned by NativeWindow.systemChrome will be one of the constants defined in the NativeWindowSystemChrome class.

The system chrome setting cannot be changed after a window is created.


Implementation
    public function get systemChrome():String

Throws
SecurityError — When trying to set to false without sufficient privilege.
 
IllegalOperationError — if the property is accessed after this window has been closed.

See also


Example

The following example :

With a reference to a display object on the window stage:
var sysChromeType:String = displayObject.stage.nativeWindow.systemChrome;

From a JavaScript routine running in an HTMLLoader in the window (or root HTML window):
var sysChromeType = window.nativeWindow.systemChrome;

The following example shows how to change the apparent system chrome and transparency settings by creating a new window and moving all child display objects to the new window:
import flash.display.NativeWindow;
import flash.display.NativeWindowSystemChrome;
import flash.display.NativeWindowInitOptions;

public function deChromeWindow(oldWindow:NativeWindow):NativeWindow{
    if(oldWindow.systemChrome != NativeWindowSystemChrome.NONE){
        var newOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
        newOptions.systemChrome = NativeWindowSystemChrome.NONE;
        newOptions.transparent = true;
        
        var newWindow:NativeWindow = new NativeWindow(newOptions);
        newWindow.stage.stageWidth = oldWindow.stage.stageWidth;
        newWindow.stage.stageHeight = oldWindow.stage.stageHeight;
        newWindow.stage.align = oldWindow.stage.align;
        newWindow.stage.scaleMode = oldWindow.stage.scaleMode;
        
        for(var i:int = 0; i < oldWindow.stage.numChildren; i++){
            newWindow.stage.addChild(oldWindow.stage.getChildAt(i));
        }
        newWindow.activate();
        oldWindow.close();
        
        return newWindow;
    }
    return oldWindow;
}

AIR-only systemMaxSizeproperty 
systemMaxSize:Point  [read-only]

The largest window size allowed by the operating system.

systemMaxSize.x is the maximum window width; systemMaxSize.y is the maximum window height.


Implementation
    public static function get systemMaxSize():Point
AIR-only systemMinSizeproperty 
systemMinSize:Point  [read-only]

The smallest window size allowed by the operating system.

systemMinSize.x is the minimum window width; systemMinSize.y is the minimum window height.


Implementation
    public static function get systemMinSize():Point
AIR-only titleproperty 
title:String  [read-write]

The window title.

The title will appear in the system chrome for the window, if displayed, as well as in other system-dependent locations (such as the task bar).


Implementation
    public function get title():String
    public function set title(value:String):void

Throws
IllegalOperationError — if the property is accessed after this window has been closed.

Example

The following example sets the title of a window object:
windowObj.title = "Window Title";
AIR-only transparentproperty 
transparent:Boolean  [read-only]

Reports the transparency setting used to create this window.

The transparent property cannot be changed after a window is created. Transparency affects both the visual appearance and the mouse behavior of the window. If the alpha value of a pixel is below a certain threshold, which varies between about .06 and .01 depending on the operating system, then the window will not capture mouse events above that pixel.


Implementation
    public function get transparent():Boolean

Throws
SecurityError — When trying to set to false without sufficient privilege.
 
IllegalOperationError — if the property is accessed after this window has been closed.

See also

AIR-only typeproperty 
type:String  [read-only]

Reports the window type setting used to create this window.

The values returned by NativeWindow.type will be one of the constants defined in the NativeWindowType class.

The type setting cannot be changed after a window is created.


Implementation
    public function get type():String

Throws
SecurityError — When trying to set to false without sufficient privilege.
 
IllegalOperationError — if the property is accessed after this window has been closed.

See also

AIR-only visibleproperty 
visible:Boolean  [read-write]

Specifies whether this window is visible.

An invisible window is not displayed on the desktop, but all window properties and methods are valid.

By default, visible is set to false. To display a window, set visible to true or call NativeWindow.activate().

Note: On Mac OS X, setting visible=false on a minimized window will not remove the window icon from the dock. If a user subsequently clicks the dock icon, the window will return to the visible state and be displayed on the desktop.


Implementation
    public function get visible():Boolean
    public function set visible(value:Boolean):void

Throws
SecurityError — When trying to set to false without sufficient privilege.
 
IllegalOperationError — if the property is accessed after this window has been closed.

See also


Example

The following example shows how to access the closed property of a window:
windowObj.visible = true;

With a reference to a display object on the window stage:
displayObj.stage.nativeWindow.visible = true;

From a JavaScript routine running in an HTMLLoader in the window (or root HTML window):
window.nativeWindow.visible = true;
AIR-only widthproperty 
width:Number  [read-write]

The width of this window in pixels.

The dimensions of a NativeWindow include any system window chrome that is displayed. The width of the usable display area inside a window is available from the Stage.stageWidth property.

Changing the width property of a window is equivalent to changing the width through the bounds property.

If the width specified is less than the minimum or greater than the maximum allowed width, either because of the minSize and maxSize properties of the window, or the minimum and maximum operating system limits, then the window width is set to the closest legal size.


Implementation
    public function get width():Number
    public function set width(value:Number):void

Throws
ArgumentError — if the value set is null or invalid.
 
IllegalOperationError — if the property is accessed after this window has been closed.

See also

AIR-only xproperty 
x:Number  [read-write]

The horizontal axis coordinate of this window's top left corner relative to the upper left corner of the operating system's desktop.

Changing the x property of a window is equivalent to changing the location through the bounds property.


Implementation
    public function get x():Number
    public function set x(value:Number):void

Throws
ArgumentError — if the value set is null or invalid.
 
IllegalOperationError — if the property is accessed after this window has been closed.

See also

AIR-only yproperty 
y:Number  [read-write]

The vertical axis coordinate of this window's top left corner relative to the upper left corner of the operating system's desktop.

Changing the y property of a window is equivalent to changing the location through the bounds property.


Implementation
    public function get y():Number
    public function set y(value:Number):void

Throws
ArgumentError — if the value set is null or invalid.
 
IllegalOperationError — if the property is accessed after this window has been closed.

See also

Constructor Detail
AIR-only NativeWindow()Constructor
public function NativeWindow(initOptions:NativeWindowInitOptions)

Creates a new NativeWindow instance and a corresponding operating system window.

The settings defined in the initOptions parameter cannot be changed after the window is created. Invalid initOptions will cause an IllegalOperationError to be thrown. Settings that are valid but not available on the current system will not throw an exception. The window capabilities specific to the current operating system can be detected, if desired, using the static NativeWindow members such as systemMaxSize.

The default window size is determined by the operating system, but can be changed by setting the window bounds. The change will not be visible if the window visible property is false.

Parameters
initOptions:NativeWindowInitOptions — An object containing the initialization properties for this window.

Throws
IllegalOperationError — If the initOptions parameter is invalid.

See also


Example

The following example creates and activates a new NativeWindow:
import flash.display.NativeWindowInitOptions;
import flash.display.NativeWindowSystemChrome;
import flash.display.NativeWindowType;
import flash.display.NativeWindow;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.geom.Rectangle;

var windowOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
windowOptions.systemChrome = NativeWindowSystemChrome.STANDARD;
windowOptions.type = NativeWindowType.NORMAL;

var newWindow:NativeWindow = new NativeWindow(windowOptions);
newWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
newWindow.stage.align = StageAlign.TOP_LEFT;
newWindow.bounds = new Rectangle(100,100,800,600);

newWindow.activate();
Method Detail
AIR-only activate()method
public function activate():void

Activates this window.

Activating a window will:

See also


Example

The following example shows how to activate a window with a reference to a flash display object on the window stage:
displayObject.stage.nativeWindow.activate();

With a reference to an instance of the NativeWindow class:
windowObj.activate();

From JavaScript in an HTML page rendered in the window (where window is the global JavaScript window object):
window.nativeWindow.activate();
AIR-only close()method 
public function close():void

Closes this window.

A "close" event is dispatched as soon as the close operation is complete. A "closing" event will not be dispatched. If cancellation of the close operation should be allowed, dispatch a closing event and check whether any registered listeners cancel the default behavior before calling the close method.

If DisplayObject instances that are currently in the window are not referenced elsewhere they will be garbage collected and destroyed.

After being closed, the NativeWindow object is still a valid reference, but accessing most properties and methods will throw an ''IllegalOperationError''.

Closed windows cannot be reopened. If the window is already closed, no action is taken and no events are dispatched.

Note: to hide a window, set the window's visible property to false.

See also


Example

The following examples show how to close a window with a reference to the NativeWindow instance (windowObj):
windowObj.close();


With a reference to a display object on the window stage:
displayObj.stage.nativeWindow.close();

From a JavaScript routine running in an HTMLLoader (or HTML root window):
window.close(); //overriddable in HTMLHost

Or:
window.nativeWindow.close(); //not overriddable

The following example illustrates how to allow cancellation of a close operation (where windowObj is the NativeWindow instance to be closed):
public function closeCommand():Boolean{
    var closeEvent:Event = new Event(Event.CLOSING,true,true);
    windowObj.dispatchEvent(closeEvent);
    if(!closeEvent.isDefaultPrevented()){
        windowObj.close();
        return true;
    } else {
      return false;
    }
}

The following example illustrates how to close a window from a JavaScript routine running in an HTMLLoader (or HTML root window), while allowing the operation to be canceled:
<script src="AIRAliases.js" type="text/javascript"></script>
<script type="text/javascript">
    var dirtyData = false;
    function closeWindow(){
            var closingEvent = new air.Event(air.Event.CLOSING,true,true);
            window.nativeWindow.dispatchEvent(closingEvent);
               if(!closingEvent.isDefaultPrevented()){
                //The following calls are equivalent (by default)
                   window.nativeWindow.close();
                //window.close(); 
               return true;
           } else {
               return false;
        }
    }
        
    function onClosing(event){
        if(dirtyData){
            event.preventDefault();
            //Save data...
        }
    }    

    window.nativeWindow.addEventListener(air.Event.CLOSING,onClosing);        
</script>
AIR-only globalToScreen()method 
public function globalToScreen(globalPoint:Point):Point

Converts a point in pixel coordinates relative to the origin of the window stage (a global point in terms of the display list), to a point on the virtual desktop.

Virtual desktop coordinates are relative to the upper, lefthand corner of the primary monitor.

Parameters

globalPoint:Point — The point on the stage to convert to a point on the screen.

Returns
Point — The specified global point relative to the desktop.

See also

AIR-only maximize()method 
public function maximize():void

Maximizes this native window according to system rules and behavior.

Calling maximize() dispatches a displayStateChange event, and, if applicable, a move and a resize event. Wheras system chrome will dispatch a displayStateChanging event that can be canceled when a maximize command is initiated by a user, your maximize logic must implement this behavior, if desired.

maximize() executes asynchronously. To detect the completion of the state change, listen for the "displayStateChange" event.

If the window is already maximized, no action is taken and no events are dispatched.

Note: On operating systems, such as Mac OS X, in which maximizing a window does not also prevent resizing, calling maximize() will zoom the window to fill the screen, but will not prevent subsequent resizing of the window. Resizing a zoomed window will also restore the display state.


Throws
IllegalOperationError — if the maximizable property of this window initOptions is false or if the method is called after this window has been closed.

See also


Example

The following example illustrates how to allow cancellation of a maximize operation:
public function maximizeWindow(nativeWin:NativeWindow):Boolean{
    if(nativeWin.displayState != NativeWindowDisplayState.MAXIMIZED){
        var beforeState:String = nativeWin.displayState;
        var afterState:String = NativeWindowDisplayState.MAXIMIZED;
        var displayStateEvent:NativeWindowDisplayStateEvent = 
            new NativeWindowDisplayStateEvent(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,
                                              true,true,beforeState,afterState);
        nativeWin.dispatchEvent(displayStateEvent);
        if(!displayStateEvent.isDefaultPrevented()){
            nativeWin.maximize();
            return true;
        } else {
          return false;
        }
     }
     return false;
}

The following example illustrates how to allow cancellation of a maximize operation:
function maximizeWindow(nativeWin){
    if(nativeWin.displayState != air.NativeWindowDisplayState.MAXIMIZED){
        var beforeState = nativeWin.displayState;
        var afterState = air.NativeWindowDisplayState.MAXIMIZED;
        var displayStateEvent = 
            new air.NativeWindowDisplayStateEvent(air.NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,
                                              true,true,beforeState,afterState);
        nativeWin.dispatchEvent(displayStateEvent);
        if(!displayStateEvent.isDefaultPrevented()){
            nativeWin.maximize();
            return true;
        } else {
          return false;
        }
     }
     return false;
}
AIR-only minimize()method 
public function minimize():void

Minimizes this native window according to system rules and behavior.

Calling minimize() dispatches a displayStateChange event, and, if applicable, a move and a resize event. Wheras system chrome will dispatch a displayStateChanging event that can be canceled when a minimize command is initiated by a user, calling minimize() directly does not. Your minimize logic may implement this behavior, if desired.

minimize() executes asynchronously. To detect the completion of the state change, listen for the "displayStateChange" event.

If the window is already minimized, no action is taken and no events are dispatched.


Throws
IllegalOperationError — if the minimizable property of this window initOptions is false or if the method is called after this window has been closed.

See also


Example

The following example illustrates how to allow cancellation of a call to minimize() by dispatching a DisplayStateChangingEvent:
public function minimizeWindow(nativeWin:NativeWindow):Boolean{
    if(nativeWin.displayState != NativeWindowDisplayState.MINIMIZED){
        var beforeState:String = nativeWin.displayState;
        var afterState:String = NativeWindowDisplayState.MINIMIZED;
        var displayStateEvent:NativeWindowDisplayStateEvent = 
            new NativeWindowDisplayStateEvent(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,
                                              true,true,beforeState,afterState);
        nativeWin.dispatchEvent(displayStateEvent);
        if(!displayStateEvent.isDefaultPrevented()){
            nativeWin.minimize();
            return true;
        } else {
          return false;
        }
     }
     return false;
}

The following example illustrates how to allow cancellation of a call to minimize() by dispatching a DisplayStateChangingEvent:
 
function minimizeWindow(nativeWin){
    if(nativeWin.displayState != air.NativeWindowDisplayState.MINIMIZED){
        var beforeState = nativeWin.displayState;
        var afterState = air.NativeWindowDisplayState.MINIMIZED;
        var displayStateEvent = 
            new air.NativeWindowDisplayStateEvent(air.NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,
                                              true,true,beforeState,afterState);
        nativeWin.dispatchEven