home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Multimedija / shufflr.air / ShufflrClient.swf / scripts / mx / core / WindowedApplication.as < prev   
Encoding:
Text File  |  2010-06-23  |  56.1 KB  |  1,744 lines

  1. package mx.core
  2. {
  3.    import flash.desktop.DockIcon;
  4.    import flash.desktop.NativeApplication;
  5.    import flash.desktop.SystemTrayIcon;
  6.    import flash.display.DisplayObject;
  7.    import flash.display.Graphics;
  8.    import flash.display.NativeWindow;
  9.    import flash.display.NativeWindowDisplayState;
  10.    import flash.display.NativeWindowResize;
  11.    import flash.display.NativeWindowSystemChrome;
  12.    import flash.display.NativeWindowType;
  13.    import flash.display.Screen;
  14.    import flash.display.Sprite;
  15.    import flash.display.StageDisplayState;
  16.    import flash.events.Event;
  17.    import flash.events.FullScreenEvent;
  18.    import flash.events.InvokeEvent;
  19.    import flash.events.MouseEvent;
  20.    import flash.events.NativeWindowBoundsEvent;
  21.    import flash.events.NativeWindowDisplayStateEvent;
  22.    import flash.filesystem.File;
  23.    import flash.geom.Point;
  24.    import flash.geom.Rectangle;
  25.    import flash.system.Capabilities;
  26.    import mx.controls.Alert;
  27.    import mx.controls.Button;
  28.    import mx.controls.FlexNativeMenu;
  29.    import mx.controls.HTML;
  30.    import mx.core.windowClasses.StatusBar;
  31.    import mx.core.windowClasses.TitleBar;
  32.    import mx.events.AIREvent;
  33.    import mx.events.EffectEvent;
  34.    import mx.events.FlexEvent;
  35.    import mx.events.FlexNativeWindowBoundsEvent;
  36.    import mx.managers.DragManager;
  37.    import mx.managers.NativeDragManagerImpl;
  38.    import mx.styles.CSSStyleDeclaration;
  39.    import mx.styles.StyleManager;
  40.    import mx.styles.StyleProxy;
  41.    
  42.    use namespace mx_internal;
  43.    
  44.    public class WindowedApplication extends Application implements IWindow
  45.    {
  46.       private static var _forceLinkNDMI:NativeDragManagerImpl;
  47.       
  48.       mx_internal static const VERSION:String = "3.5.0.12683";
  49.       
  50.       private static const HEADER_PADDING:Number = 4;
  51.       
  52.       private static const MOUSE_SLACK:Number = 5;
  53.       
  54.       private static var _statusBarStyleFilters:Object = {
  55.          "statusBarBackgroundColor":"statusBarBackgroundColor",
  56.          "statusBarBackgroundSkin":"statusBarBackgroundSkin",
  57.          "statusTextStyleName":"statusTextStyleName"
  58.       };
  59.       
  60.       private static var _titleBarStyleFilters:Object = {
  61.          "buttonAlignment":"buttonAlignment",
  62.          "buttonPadding":"buttonPadding",
  63.          "closeButtonSkin":"closeButtonSkin",
  64.          "cornerRadius":"cornerRadius",
  65.          "headerHeight":"headerHeight",
  66.          "maximizeButtonSkin":"maximizeButtonSkin",
  67.          "minimizeButtonSkin":"minimizeButtonSkin",
  68.          "restoreButtonSkin":"restoreButtonSkin",
  69.          "titleAlignment":"titleAlignment",
  70.          "titleBarBackgroundSkin":"titleBarBackgroundSkin",
  71.          "titleBarButtonPadding":"titleBarButtonPadding",
  72.          "titleBarColors":"titleBarColors",
  73.          "titleTextStyleName":"titleTextStyleName"
  74.       };
  75.       
  76.       private var showGripperChanged:Boolean = true;
  77.       
  78.       private var shouldShowTitleBar:Boolean;
  79.       
  80.       private var invokesPending:Boolean = true;
  81.       
  82.       private var _maxWidth:Number = 0;
  83.       
  84.       mx_internal var titleBarBackground:IFlexDisplayObject;
  85.       
  86.       private var _maxHeight:Number = 0;
  87.       
  88.       private var windowBoundsChanged:Boolean = true;
  89.       
  90.       private var _menu:FlexNativeMenu;
  91.       
  92.       private var boundsChanged:Boolean = false;
  93.       
  94.       private var _showStatusBar:Boolean = true;
  95.       
  96.       private var minHeightChanged:Boolean = false;
  97.       
  98.       private var menuChanged:Boolean = false;
  99.       
  100.       private var statusChanged:Boolean = false;
  101.       
  102.       private var titleIconChanged:Boolean = false;
  103.       
  104.       private var prevX:Number;
  105.       
  106.       private var prevY:Number;
  107.       
  108.       private var maxHeightChanged:Boolean = false;
  109.       
  110.       private var gripper:Button;
  111.       
  112.       private var _showTitleBar:Boolean = true;
  113.       
  114.       private var _minHeight:Number = 0;
  115.       
  116.       private var lastDisplayState:String = "normal";
  117.       
  118.       private var _dockIconMenu:FlexNativeMenu;
  119.       
  120.       private var _nativeWindow:NativeWindow;
  121.       
  122.       private var _nativeWindowVisible:Boolean = true;
  123.       
  124.       mx_internal var statusBarBackground:IFlexDisplayObject;
  125.       
  126.       private var showTitleBarChanged:Boolean = true;
  127.       
  128.       private var toMax:Boolean = false;
  129.       
  130.       private var _alwaysInFront:Boolean = false;
  131.       
  132.       private var gripperHit:Sprite;
  133.       
  134.       private var _showGripper:Boolean = true;
  135.       
  136.       private var oldX:Number;
  137.       
  138.       private var oldY:Number;
  139.       
  140.       private var initialInvokes:Array;
  141.       
  142.       private var _status:String = "";
  143.       
  144.       private var ucCount:Number = 0;
  145.       
  146.       private var _gripperPadding:Number = 3;
  147.       
  148.       private var _systemTrayIconMenu:FlexNativeMenu;
  149.       
  150.       private var _statusBar:UIComponent;
  151.       
  152.       private var titleChanged:Boolean = false;
  153.       
  154.       private var _title:String = "";
  155.       
  156.       private var _statusBarFactory:IFactory = new ClassFactory(StatusBar);
  157.       
  158.       private var statusBarFactoryChanged:Boolean = false;
  159.       
  160.       private var _titleIcon:Class;
  161.       
  162.       private var appViewMetrics:EdgeMetrics;
  163.       
  164.       private var minWidthChanged:Boolean = false;
  165.       
  166.       private var maxWidthChanged:Boolean = false;
  167.       
  168.       private var activateOnOpen:Boolean = true;
  169.       
  170.       private var _titleBarFactory:IFactory = new ClassFactory(TitleBar);
  171.       
  172.       private var titleBarFactoryChanged:Boolean = false;
  173.       
  174.       private var showStatusBarChanged:Boolean = true;
  175.       
  176.       private var _bounds:Rectangle = new Rectangle(0,0,0,0);
  177.       
  178.       private var _minWidth:Number = 0;
  179.       
  180.       private var _titleBar:UIComponent;
  181.       
  182.       public function WindowedApplication()
  183.       {
  184.          super();
  185.          addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
  186.          addEventListener(FlexEvent.PREINITIALIZE,preinitializeHandler);
  187.          addEventListener(FlexEvent.UPDATE_COMPLETE,updateComplete_handler);
  188.          addEventListener(FlexEvent.CREATION_COMPLETE,creationCompleteHandler);
  189.          var _loc1_:NativeApplication = NativeApplication.nativeApplication;
  190.          _loc1_.addEventListener(Event.ACTIVATE,nativeApplication_activateHandler);
  191.          _loc1_.addEventListener(Event.DEACTIVATE,nativeApplication_deactivateHandler);
  192.          _loc1_.addEventListener(Event.NETWORK_CHANGE,nativeApplication_networkChangeHandler);
  193.          _loc1_.addEventListener(InvokeEvent.INVOKE,nativeApplication_invokeHandler);
  194.          initialInvokes = new Array();
  195.          DragManager.isDragging;
  196.       }
  197.       
  198.       public function orderInBackOf(param1:IWindow) : Boolean
  199.       {
  200.          if(Boolean(nativeWindow) && !nativeWindow.closed)
  201.          {
  202.             return nativeWindow.orderInBackOf(param1.nativeWindow);
  203.          }
  204.          return false;
  205.       }
  206.       
  207.       public function set statusBarFactory(param1:IFactory) : void
  208.       {
  209.          _statusBarFactory = param1;
  210.          statusBarFactoryChanged = true;
  211.          invalidateProperties();
  212.          dispatchEvent(new Event("statusBarFactoryChanged"));
  213.       }
  214.       
  215.       private function enterFrameHandler(param1:Event) : void
  216.       {
  217.          removeEventListener(Event.ENTER_FRAME,enterFrameHandler);
  218.          if(stage.nativeWindow.closed)
  219.          {
  220.             return;
  221.          }
  222.          stage.nativeWindow.visible = _nativeWindowVisible;
  223.          dispatchEvent(new AIREvent(AIREvent.WINDOW_COMPLETE));
  224.          dispatchPendingInvokes();
  225.          if(_nativeWindowVisible && activateOnOpen)
  226.          {
  227.             stage.nativeWindow.activate();
  228.          }
  229.          stage.nativeWindow.alwaysInFront = _alwaysInFront;
  230.       }
  231.       
  232.       [Bindable("windowComplete")]
  233.       [Bindable("minHeightChanged")]
  234.       override public function get minHeight() : Number
  235.       {
  236.          if(Boolean(nativeWindow) && !minHeightChanged)
  237.          {
  238.             return nativeWindow.minSize.y - chromeHeight();
  239.          }
  240.          return _minHeight;
  241.       }
  242.       
  243.       private function window_closeHandler(param1:Event) : void
  244.       {
  245.          dispatchEvent(new Event("close"));
  246.       }
  247.       
  248.       private function nativeApplication_deactivateHandler(param1:Event) : void
  249.       {
  250.          dispatchEvent(new AIREvent(AIREvent.APPLICATION_DEACTIVATE));
  251.       }
  252.       
  253.       override public function set minHeight(param1:Number) : void
  254.       {
  255.          _minHeight = param1;
  256.          minHeightChanged = true;
  257.          invalidateProperties();
  258.       }
  259.       
  260.       private function chromeHeight() : Number
  261.       {
  262.          return nativeWindow.height - systemManager.stage.stageHeight;
  263.       }
  264.       
  265.       public function get showStatusBar() : Boolean
  266.       {
  267.          return _showStatusBar;
  268.       }
  269.       
  270.       override public function set height(param1:Number) : void
  271.       {
  272.          if(param1 < minHeight)
  273.          {
  274.             param1 = minHeight;
  275.          }
  276.          else if(param1 > maxHeight)
  277.          {
  278.             param1 = maxHeight;
  279.          }
  280.          _bounds.height = param1;
  281.          boundsChanged = true;
  282.          invalidateProperties();
  283.          invalidateSize();
  284.          mx_internal::invalidateViewMetricsAndPadding();
  285.       }
  286.       
  287.       private function mouseMoveHandler(param1:MouseEvent) : void
  288.       {
  289.          stage.nativeWindow.x += param1.stageX - prevX;
  290.          stage.nativeWindow.y += param1.stageY - prevY;
  291.       }
  292.       
  293.       [Bindable("titleChanged")]
  294.       public function get title() : String
  295.       {
  296.          return _title;
  297.       }
  298.       
  299.       protected function mouseDownHandler(param1:MouseEvent) : void
  300.       {
  301.          var _loc2_:int = 0;
  302.          var _loc3_:int = 0;
  303.          if(systemManager.stage.nativeWindow.systemChrome != "none")
  304.          {
  305.             return;
  306.          }
  307.          if(param1.target == gripperHit)
  308.          {
  309.             startResize(NativeWindowResize.BOTTOM_RIGHT);
  310.             param1.stopPropagation();
  311.          }
  312.          else
  313.          {
  314.             _loc2_ = Number(getStyle("borderThickness")) + 6;
  315.             _loc3_ = 12;
  316.             if(param1.stageY < Number(getStyle("borderThickness")))
  317.             {
  318.                if(param1.stageX < _loc3_)
  319.                {
  320.                   startResize(NativeWindowResize.TOP_LEFT);
  321.                }
  322.                else if(param1.stageX > width - _loc3_)
  323.                {
  324.                   startResize(NativeWindowResize.TOP_RIGHT);
  325.                }
  326.                else
  327.                {
  328.                   startResize(NativeWindowResize.TOP);
  329.                }
  330.             }
  331.             else if(param1.stageY > height - _loc2_)
  332.             {
  333.                if(param1.stageX < _loc3_)
  334.                {
  335.                   startResize(NativeWindowResize.BOTTOM_LEFT);
  336.                }
  337.                else if(param1.stageX > width - _loc3_)
  338.                {
  339.                   startResize(NativeWindowResize.BOTTOM_RIGHT);
  340.                }
  341.                else
  342.                {
  343.                   startResize(NativeWindowResize.BOTTOM);
  344.                }
  345.             }
  346.             else if(param1.stageX < _loc2_)
  347.             {
  348.                if(param1.stageY < _loc3_)
  349.                {
  350.                   startResize(NativeWindowResize.TOP_LEFT);
  351.                }
  352.                else if(param1.stageY > height - _loc3_)
  353.                {
  354.                   startResize(NativeWindowResize.BOTTOM_LEFT);
  355.                }
  356.                else
  357.                {
  358.                   startResize(NativeWindowResize.LEFT);
  359.                }
  360.                param1.stopPropagation();
  361.             }
  362.             else if(param1.stageX > width - _loc2_)
  363.             {
  364.                if(param1.stageY < _loc3_)
  365.                {
  366.                   startResize(NativeWindowResize.TOP_RIGHT);
  367.                }
  368.                else if(param1.stageY > height - _loc3_)
  369.                {
  370.                   startResize(NativeWindowResize.BOTTOM_RIGHT);
  371.                }
  372.                else
  373.                {
  374.                   startResize(NativeWindowResize.RIGHT);
  375.                }
  376.             }
  377.          }
  378.       }
  379.       
  380.       override public function get viewMetrics() : EdgeMetrics
  381.       {
  382.          var _loc3_:Number = NaN;
  383.          var _loc4_:Number = NaN;
  384.          var _loc1_:EdgeMetrics = super.viewMetrics;
  385.          var _loc2_:EdgeMetrics = new EdgeMetrics(_loc1_.left,_loc1_.top,_loc1_.right,_loc1_.bottom);
  386.          if(showTitleBar)
  387.          {
  388.             _loc3_ = getHeaderHeight();
  389.             if(!isNaN(_loc3_))
  390.             {
  391.                _loc2_.top += _loc3_;
  392.             }
  393.          }
  394.          if(_showStatusBar)
  395.          {
  396.             _loc4_ = getStatusBarHeight();
  397.             if(!isNaN(_loc4_))
  398.             {
  399.                _loc2_.bottom += _loc4_;
  400.             }
  401.          }
  402.          return _loc2_;
  403.       }
  404.       
  405.       private function window_moveHandler(param1:NativeWindowBoundsEvent) : void
  406.       {
  407.          dispatchEvent(new FlexNativeWindowBoundsEvent(FlexNativeWindowBoundsEvent.WINDOW_MOVE,param1.bubbles,param1.cancelable,param1.beforeBounds,param1.afterBounds));
  408.       }
  409.       
  410.       public function get applicationID() : String
  411.       {
  412.          return nativeApplication.applicationID;
  413.       }
  414.       
  415.       protected function get statusBarStyleFilters() : Object
  416.       {
  417.          return _statusBarStyleFilters;
  418.       }
  419.       
  420.       [Bindable("windowComplete")]
  421.       [Bindable("show")]
  422.       [Bindable("hide")]
  423.       override public function get visible() : Boolean
  424.       {
  425.          if(Boolean(nativeWindow) && Boolean(nativeWindow.closed))
  426.          {
  427.             return false;
  428.          }
  429.          if(nativeWindow)
  430.          {
  431.             return nativeWindow.visible;
  432.          }
  433.          return _nativeWindowVisible;
  434.       }
  435.       
  436.       public function get minimizable() : Boolean
  437.       {
  438.          if(!nativeWindow.closed)
  439.          {
  440.             return nativeWindow.minimizable;
  441.          }
  442.          return false;
  443.       }
  444.       
  445.       private function dispatchPendingInvokes() : void
  446.       {
  447.          var _loc1_:InvokeEvent = null;
  448.          invokesPending = false;
  449.          for each(_loc1_ in initialInvokes)
  450.          {
  451.             dispatchEvent(_loc1_);
  452.          }
  453.          initialInvokes = null;
  454.       }
  455.       
  456.       public function restore() : void
  457.       {
  458.          var _loc1_:NativeWindowDisplayStateEvent = null;
  459.          if(!nativeWindow.closed)
  460.          {
  461.             if(stage.nativeWindow.displayState == NativeWindowDisplayState.MAXIMIZED)
  462.             {
  463.                _loc1_ = new NativeWindowDisplayStateEvent(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,false,true,NativeWindowDisplayState.MAXIMIZED,NativeWindowDisplayState.NORMAL);
  464.                stage.nativeWindow.dispatchEvent(_loc1_);
  465.                if(!_loc1_.isDefaultPrevented())
  466.                {
  467.                   nativeWindow.restore();
  468.                }
  469.             }
  470.             else if(stage.nativeWindow.displayState == NativeWindowDisplayState.MINIMIZED)
  471.             {
  472.                _loc1_ = new NativeWindowDisplayStateEvent(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,false,true,NativeWindowDisplayState.MINIMIZED,NativeWindowDisplayState.NORMAL);
  473.                stage.nativeWindow.dispatchEvent(_loc1_);
  474.                if(!_loc1_.isDefaultPrevented())
  475.                {
  476.                   nativeWindow.restore();
  477.                }
  478.             }
  479.          }
  480.       }
  481.       
  482.       public function set showStatusBar(param1:Boolean) : void
  483.       {
  484.          if(_showStatusBar == param1)
  485.          {
  486.             return;
  487.          }
  488.          _showStatusBar = param1;
  489.          showStatusBarChanged = true;
  490.          invalidateProperties();
  491.          invalidateDisplayList();
  492.       }
  493.       
  494.       private function getHeaderHeight() : Number
  495.       {
  496.          if(!nativeWindow.closed)
  497.          {
  498.             if(getStyle("headerHeight") != null)
  499.             {
  500.                return getStyle("headerHeight");
  501.             }
  502.             if(systemManager.stage.nativeWindow.systemChrome != "none")
  503.             {
  504.                return 0;
  505.             }
  506.             if(titleBar)
  507.             {
  508.                return titleBar.getExplicitOrMeasuredHeight();
  509.             }
  510.          }
  511.          return 0;
  512.       }
  513.       
  514.       [Bindable("windowComplete")]
  515.       [Bindable("minWidthChanged")]
  516.       override public function get minWidth() : Number
  517.       {
  518.          if(Boolean(nativeWindow) && !minWidthChanged)
  519.          {
  520.             return nativeWindow.minSize.x - chromeWidth();
  521.          }
  522.          return _minWidth;
  523.       }
  524.       
  525.       public function get systemTrayIconMenu() : FlexNativeMenu
  526.       {
  527.          return _systemTrayIconMenu;
  528.       }
  529.       
  530.       public function minimize() : void
  531.       {
  532.          var _loc1_:NativeWindowDisplayStateEvent = null;
  533.          if(!nativeWindow.closed)
  534.          {
  535.             _loc1_ = new NativeWindowDisplayStateEvent(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,false,true,nativeWindow.displayState,NativeWindowDisplayState.MINIMIZED);
  536.             stage.nativeWindow.dispatchEvent(_loc1_);
  537.             if(!_loc1_.isDefaultPrevented())
  538.             {
  539.                stage.nativeWindow.minimize();
  540.             }
  541.          }
  542.       }
  543.       
  544.       public function get titleBar() : UIComponent
  545.       {
  546.          return _titleBar;
  547.       }
  548.       
  549.       public function get resizable() : Boolean
  550.       {
  551.          if(nativeWindow.closed)
  552.          {
  553.             return false;
  554.          }
  555.          return nativeWindow.resizable;
  556.       }
  557.       
  558.       private function nativeApplication_invokeHandler(param1:InvokeEvent) : void
  559.       {
  560.          if(invokesPending)
  561.          {
  562.             initialInvokes.push(param1);
  563.          }
  564.          else
  565.          {
  566.             dispatchEvent(param1);
  567.          }
  568.       }
  569.       
  570.       protected function get bounds() : Rectangle
  571.       {
  572.          return nativeWindow.bounds;
  573.       }
  574.       
  575.       public function set title(param1:String) : void
  576.       {
  577.          _title = param1;
  578.          titleChanged = true;
  579.          invalidateProperties();
  580.          invalidateSize();
  581.          mx_internal::invalidateViewMetricsAndPadding();
  582.          invalidateDisplayList();
  583.          dispatchEvent(new Event("titleChanged"));
  584.       }
  585.       
  586.       public function get showTitleBar() : Boolean
  587.       {
  588.          return _showTitleBar;
  589.       }
  590.       
  591.       public function get nativeApplication() : NativeApplication
  592.       {
  593.          return NativeApplication.nativeApplication;
  594.       }
  595.       
  596.       override protected function menuItemSelectHandler(param1:Event) : void
  597.       {
  598.          var _loc3_:Rectangle = null;
  599.          var _loc4_:int = 0;
  600.          var _loc5_:int = 0;
  601.          var _loc6_:Number = NaN;
  602.          var _loc7_:int = 0;
  603.          var _loc8_:int = 0;
  604.          var _loc9_:int = 0;
  605.          var _loc10_:int = 0;
  606.          var _loc11_:HTML = null;
  607.          var _loc12_:Window = null;
  608.          var _loc2_:File = File.applicationDirectory.resolvePath(viewSourceURL);
  609.          if(_loc2_.exists)
  610.          {
  611.             _loc3_ = Screen.mainScreen.visibleBounds;
  612.             _loc4_ = _loc3_.width;
  613.             _loc5_ = _loc3_.height;
  614.             _loc6_ = Math.min(_loc4_,_loc5_);
  615.             _loc7_ = _loc6_ * 0.9;
  616.             _loc8_ = _loc7_ * 0.618;
  617.             _loc9_ = (_loc4_ - _loc7_) / 2;
  618.             _loc10_ = (_loc5_ - _loc8_) / 2;
  619.             _loc11_ = new HTML();
  620.             _loc11_.width = _loc7_;
  621.             _loc11_.height = _loc8_;
  622.             _loc11_.location = _loc2_.url;
  623.             _loc12_ = new Window();
  624.             _loc12_.type = NativeWindowType.UTILITY;
  625.             _loc12_.systemChrome = NativeWindowSystemChrome.STANDARD;
  626.             _loc12_.title = resourceManager.getString("core","viewSource");
  627.             _loc12_.width = _loc7_;
  628.             _loc12_.height = _loc8_;
  629.             _loc12_.addChild(_loc11_);
  630.             _loc12_.addEventListener(FlexNativeWindowBoundsEvent.WINDOW_RESIZE,viewSourceResizeHandler(_loc11_),false,0,true);
  631.             _loc11_.htmlLoader.navigateInSystemBrowser = true;
  632.             addEventListener(Event.CLOSING,viewSourceCloseHandler(_loc12_),false,0,true);
  633.             _loc12_.open();
  634.             _loc12_.move(_loc9_,_loc10_);
  635.          }
  636.          else
  637.          {
  638.             Alert.show(resourceManager.getString("core","badFile"));
  639.          }
  640.       }
  641.       
  642.       private function viewSourceResizeHandler(param1:HTML) : Function
  643.       {
  644.          var html:HTML = param1;
  645.          return function(param1:FlexNativeWindowBoundsEvent):void
  646.          {
  647.             var _loc2_:* = param1.target;
  648.             html.width = _loc2_.width;
  649.             html.height = _loc2_.height;
  650.          };
  651.       }
  652.       
  653.       public function set menu(param1:FlexNativeMenu) : void
  654.       {
  655.          _menu = param1;
  656.          menuChanged = true;
  657.       }
  658.       
  659.       public function get statusBar() : UIComponent
  660.       {
  661.          return _statusBar;
  662.       }
  663.       
  664.       [Bindable("windowComplete")]
  665.       [Bindable("maxWidthChanged")]
  666.       override public function get maxWidth() : Number
  667.       {
  668.          if(Boolean(nativeWindow) && !maxWidthChanged)
  669.          {
  670.             return nativeWindow.maxSize.x - chromeWidth();
  671.          }
  672.          return _maxWidth;
  673.       }
  674.       
  675.       private function windowMinimizeHandler(param1:Event) : void
  676.       {
  677.          if(!nativeWindow.closed)
  678.          {
  679.             stage.nativeWindow.minimize();
  680.          }
  681.          removeEventListener(EffectEvent.EFFECT_END,windowMinimizeHandler);
  682.       }
  683.       
  684.       public function get dockIconMenu() : FlexNativeMenu
  685.       {
  686.          return _dockIconMenu;
  687.       }
  688.       
  689.       private function window_boundsHandler(param1:NativeWindowBoundsEvent) : void
  690.       {
  691.          var _loc3_:Rectangle = null;
  692.          var _loc4_:Boolean = false;
  693.          var _loc2_:Rectangle = param1.afterBounds;
  694.          if(param1.type == NativeWindowBoundsEvent.MOVING)
  695.          {
  696.             dispatchEvent(param1);
  697.             if(param1.isDefaultPrevented())
  698.             {
  699.                return;
  700.             }
  701.          }
  702.          else
  703.          {
  704.             dispatchEvent(param1);
  705.             if(param1.isDefaultPrevented())
  706.             {
  707.                return;
  708.             }
  709.             _loc4_ = false;
  710.             if(_loc2_.width < nativeWindow.minSize.x)
  711.             {
  712.                _loc4_ = true;
  713.                if(_loc2_.x != param1.beforeBounds.x && !isNaN(oldX))
  714.                {
  715.                   _loc2_.x = oldX;
  716.                }
  717.                _loc2_.width = nativeWindow.minSize.x;
  718.             }
  719.             else if(_loc2_.width > nativeWindow.maxSize.x)
  720.             {
  721.                _loc4_ = true;
  722.                if(_loc2_.x != param1.beforeBounds.x && !isNaN(oldX))
  723.                {
  724.                   _loc2_.x = oldX;
  725.                }
  726.                _loc2_.width = nativeWindow.maxSize.x;
  727.             }
  728.             if(_loc2_.height < nativeWindow.minSize.y)
  729.             {
  730.                _loc4_ = true;
  731.                if(param1.afterBounds.y != param1.beforeBounds.y && !isNaN(oldY))
  732.                {
  733.                   _loc2_.y = oldY;
  734.                }
  735.                _loc2_.height = nativeWindow.minSize.y;
  736.             }
  737.             else if(_loc2_.height > nativeWindow.maxSize.y)
  738.             {
  739.                _loc4_ = true;
  740.                if(param1.afterBounds.y != param1.beforeBounds.y && !isNaN(oldY))
  741.                {
  742.                   _loc2_.y = oldY;
  743.                }
  744.                _loc2_.height = nativeWindow.maxSize.y;
  745.             }
  746.             if(_loc4_)
  747.             {
  748.                param1.preventDefault();
  749.                stage.nativeWindow.bounds = _loc2_;
  750.                windowBoundsChanged = true;
  751.                invalidateProperties();
  752.             }
  753.          }
  754.          oldX = _loc2_.x;
  755.          oldY = _loc2_.y;
  756.       }
  757.       
  758.       public function get showGripper() : Boolean
  759.       {
  760.          return _showGripper;
  761.       }
  762.       
  763.       public function maximize() : void
  764.       {
  765.          var _loc1_:NativeWindowDisplayStateEvent = null;
  766.          if(!nativeWindow || !nativeWindow.maximizable || Boolean(nativeWindow.closed))
  767.          {
  768.             return;
  769.          }
  770.          if(systemManager.stage.nativeWindow.displayState != NativeWindowDisplayState.MAXIMIZED)
  771.          {
  772.             _loc1_ = new NativeWindowDisplayStateEvent(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,false,true,systemManager.stage.nativeWindow.displayState,NativeWindowDisplayState.MAXIMIZED);
  773.             systemManager.stage.nativeWindow.dispatchEvent(_loc1_);
  774.             if(!_loc1_.isDefaultPrevented())
  775.             {
  776.                invalidateProperties();
  777.                invalidateSize();
  778.                invalidateDisplayList();
  779.                toMax = true;
  780.             }
  781.          }
  782.       }
  783.       
  784.       private function windowMaximizeHandler(param1:Event) : void
  785.       {
  786.          removeEventListener(EffectEvent.EFFECT_END,windowMaximizeHandler);
  787.          if(!nativeWindow.closed)
  788.          {
  789.             stage.nativeWindow.maximize();
  790.          }
  791.       }
  792.       
  793.       public function set autoExit(param1:Boolean) : void
  794.       {
  795.          nativeApplication.autoExit = param1;
  796.       }
  797.       
  798.       private function nativeWindow_deactivateHandler(param1:Event) : void
  799.       {
  800.          dispatchEvent(new AIREvent(AIREvent.WINDOW_DEACTIVATE));
  801.       }
  802.       
  803.       public function get nativeWindow() : NativeWindow
  804.       {
  805.          if(systemManager != null && systemManager.stage != null)
  806.          {
  807.             return systemManager.stage.nativeWindow;
  808.          }
  809.          return null;
  810.       }
  811.       
  812.       override public function set visible(param1:Boolean) : void
  813.       {
  814.          setVisible(param1);
  815.       }
  816.       
  817.       public function orderToBack() : Boolean
  818.       {
  819.          if(Boolean(nativeWindow) && !nativeWindow.closed)
  820.          {
  821.             return nativeWindow.orderToBack();
  822.          }
  823.          return false;
  824.       }
  825.       
  826.       [Bindable("titleIconChanged")]
  827.       public function get titleIcon() : Class
  828.       {
  829.          return _titleIcon;
  830.       }
  831.       
  832.       private function creationCompleteHandler(param1:Event) : void
  833.       {
  834.          addEventListener(Event.ENTER_FRAME,enterFrameHandler);
  835.          _nativeWindow = systemManager.stage.nativeWindow;
  836.       }
  837.       
  838.       public function activate() : void
  839.       {
  840.          if(!systemManager.stage.nativeWindow.closed)
  841.          {
  842.             systemManager.stage.nativeWindow.activate();
  843.          }
  844.       }
  845.       
  846.       public function get alwaysInFront() : Boolean
  847.       {
  848.          if(Boolean(_nativeWindow) && !_nativeWindow.closed)
  849.          {
  850.             return nativeWindow.alwaysInFront;
  851.          }
  852.          return _alwaysInFront;
  853.       }
  854.       
  855.       private function windowUnminimizeHandler(param1:Event) : void
  856.       {
  857.          removeEventListener(EffectEvent.EFFECT_END,windowUnminimizeHandler);
  858.       }
  859.       
  860.       private function window_closingHandler(param1:Event) : void
  861.       {
  862.          var _loc2_:Event = new Event("closing",true,true);
  863.          dispatchEvent(_loc2_);
  864.          if(_loc2_.isDefaultPrevented())
  865.          {
  866.             param1.preventDefault();
  867.          }
  868.          else if(getStyle("closeEffect") && stage.nativeWindow.transparent == true)
  869.          {
  870.             addEventListener(EffectEvent.EFFECT_END,window_closeEffectEndHandler);
  871.             dispatchEvent(new Event("windowClose"));
  872.             param1.preventDefault();
  873.          }
  874.       }
  875.       
  876.       [Bindable("statusBarFactoryChanged")]
  877.       public function get statusBarFactory() : IFactory
  878.       {
  879.          return _statusBarFactory;
  880.       }
  881.       
  882.       private function windowUnmaximizeHandler(param1:Event) : void
  883.       {
  884.          removeEventListener(EffectEvent.EFFECT_END,windowUnmaximizeHandler);
  885.          if(!nativeWindow.closed)
  886.          {
  887.             stage.nativeWindow.restore();
  888.          }
  889.       }
  890.       
  891.       override protected function createChildren() : void
  892.       {
  893.          var _loc1_:String = null;
  894.          var _loc2_:CSSStyleDeclaration = null;
  895.          super.createChildren();
  896.          if(getStyle("showFlexChrome") == false || getStyle("showFlexChrome") == "false")
  897.          {
  898.             setStyle("borderStyle","none");
  899.             setStyle("backgroundAlpha",0);
  900.             return;
  901.          }
  902.          if(!_statusBar)
  903.          {
  904.             _statusBar = statusBarFactory.newInstance();
  905.             _statusBar.styleName = new StyleProxy(this,statusBarStyleFilters);
  906.             rawChildren.addChild(DisplayObject(_statusBar));
  907.             showStatusBarChanged = true;
  908.             statusBarFactoryChanged = false;
  909.          }
  910.          if(systemManager.stage.nativeWindow.systemChrome != "none")
  911.          {
  912.             setStyle("borderStyle","none");
  913.             return;
  914.          }
  915.          if(!_titleBar)
  916.          {
  917.             _titleBar = titleBarFactory.newInstance();
  918.             _titleBar.styleName = new StyleProxy(this,titleBarStyleFilters);
  919.             rawChildren.addChild(DisplayObject(titleBar));
  920.             showTitleBarChanged = true;
  921.             titleBarFactoryChanged = false;
  922.          }
  923.          if(!gripper)
  924.          {
  925.             gripper = new Button();
  926.             _loc1_ = getStyle("gripperStyleName");
  927.             if(_loc1_)
  928.             {
  929.                _loc2_ = StyleManager.getStyleDeclaration("." + _loc1_);
  930.                gripper.styleName = _loc1_;
  931.             }
  932.             rawChildren.addChild(gripper);
  933.             gripperHit = new Sprite();
  934.             gripperHit.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
  935.             rawChildren.addChild(gripperHit);
  936.          }
  937.       }
  938.       
  939.       public function exit() : void
  940.       {
  941.          nativeApplication.exit();
  942.       }
  943.       
  944.       private function mouseUpHandler(param1:MouseEvent) : void
  945.       {
  946.          removeEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
  947.          removeEventListener(MouseEvent.MOUSE_UP,mouseUpHandler);
  948.       }
  949.       
  950.       [Bindable("heightChanged")]
  951.       override public function get height() : Number
  952.       {
  953.          return _bounds.height;
  954.       }
  955.       
  956.       override public function set minWidth(param1:Number) : void
  957.       {
  958.          _minWidth = param1;
  959.          minWidthChanged = true;
  960.          invalidateProperties();
  961.       }
  962.       
  963.       public function getStatusBarHeight() : Number
  964.       {
  965.          if(_statusBar)
  966.          {
  967.             return _statusBar.getExplicitOrMeasuredHeight();
  968.          }
  969.          return 0;
  970.       }
  971.       
  972.       private function updateComplete_handler(param1:FlexEvent) : void
  973.       {
  974.          if(ucCount == 1)
  975.          {
  976.             dispatchEvent(new Event("initialLayoutComplete"));
  977.             removeEventListener(FlexEvent.UPDATE_COMPLETE,updateComplete_handler);
  978.          }
  979.          else
  980.          {
  981.             ++ucCount;
  982.          }
  983.       }
  984.       
  985.       public function set systemTrayIconMenu(param1:FlexNativeMenu) : void
  986.       {
  987.          _systemTrayIconMenu = param1;
  988.          if(NativeApplication.supportsSystemTrayIcon)
  989.          {
  990.             if(nativeApplication.icon is SystemTrayIcon)
  991.             {
  992.                SystemTrayIcon(nativeApplication.icon).menu = param1.nativeMenu;
  993.             }
  994.          }
  995.       }
  996.       
  997.       public function orderToFront() : Boolean
  998.       {
  999.          if(Boolean(nativeWindow) && !nativeWindow.closed)
  1000.          {
  1001.             return nativeWindow.orderToFront();
  1002.          }
  1003.          return false;
  1004.       }
  1005.       
  1006.       public function get type() : String
  1007.       {
  1008.          if(nativeWindow.closed)
  1009.          {
  1010.             return "standard";
  1011.          }
  1012.          return nativeWindow.type;
  1013.       }
  1014.       
  1015.       protected function get titleBarStyleFilters() : Object
  1016.       {
  1017.          return _titleBarStyleFilters;
  1018.       }
  1019.       
  1020.       private function window_displayStateChangeHandler(param1:NativeWindowDisplayStateEvent) : void
  1021.       {
  1022.          dispatchEvent(param1);
  1023.          height = systemManager.stage.stageHeight;
  1024.          width = systemManager.stage.stageWidth;
  1025.       }
  1026.       
  1027.       public function orderInFrontOf(param1:IWindow) : Boolean
  1028.       {
  1029.          if(Boolean(nativeWindow) && !nativeWindow.closed)
  1030.          {
  1031.             return nativeWindow.orderInFrontOf(param1.nativeWindow);
  1032.          }
  1033.          return false;
  1034.       }
  1035.       
  1036.       private function nativeApplication_activateHandler(param1:Event) : void
  1037.       {
  1038.          dispatchEvent(new AIREvent(AIREvent.APPLICATION_ACTIVATE));
  1039.       }
  1040.       
  1041.       public function get transparent() : Boolean
  1042.       {
  1043.          if(nativeWindow.closed)
  1044.          {
  1045.             return false;
  1046.          }
  1047.          return nativeWindow.transparent;
  1048.       }
  1049.       
  1050.       private function startMove(param1:MouseEvent) : void
  1051.       {
  1052.          addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
  1053.          addEventListener(MouseEvent.MOUSE_UP,mouseUpHandler);
  1054.          prevX = param1.stageX;
  1055.          prevY = param1.stageY;
  1056.       }
  1057.       
  1058.       override public function set maxHeight(param1:Number) : void
  1059.       {
  1060.          _maxHeight = param1;
  1061.          maxHeightChanged = true;
  1062.          invalidateProperties();
  1063.       }
  1064.       
  1065.       private function preinitializeHandler(param1:Event = null) : void
  1066.       {
  1067.          systemManager.stage.nativeWindow.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING,window_displayStateChangingHandler);
  1068.          systemManager.stage.nativeWindow.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE,window_displayStateChangeHandler);
  1069.          systemManager.stage.nativeWindow.addEventListener("closing",window_closingHandler);
  1070.          systemManager.stage.nativeWindow.addEventListener("close",window_closeHandler,false,0,true);
  1071.          if(systemManager.stage.nativeWindow.active)
  1072.          {
  1073.             dispatchEvent(new AIREvent(AIREvent.WINDOW_ACTIVATE));
  1074.          }
  1075.          systemManager.stage.nativeWindow.addEventListener("activate",nativeWindow_activateHandler,false,0,true);
  1076.          systemManager.stage.nativeWindow.addEventListener("deactivate",nativeWindow_deactivateHandler,false,0,true);
  1077.          systemManager.stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.MOVING,window_boundsHandler);
  1078.          systemManager.stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.MOVE,window_moveHandler);
  1079.          systemManager.stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZING,window_boundsHandler);
  1080.          systemManager.stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZE,window_resizeHandler);
  1081.          systemManager.stage.addEventListener(FullScreenEvent.FULL_SCREEN,stage_fullScreenHandler);
  1082.       }
  1083.       
  1084.       public function get menu() : FlexNativeMenu
  1085.       {
  1086.          return _menu;
  1087.       }
  1088.       
  1089.       private function window_displayStateChangingHandler(param1:NativeWindowDisplayStateEvent) : void
  1090.       {
  1091.          dispatchEvent(param1);
  1092.          if(param1.isDefaultPrevented())
  1093.          {
  1094.             return;
  1095.          }
  1096.          if(param1.afterDisplayState == NativeWindowDisplayState.MINIMIZED)
  1097.          {
  1098.             if(getStyle("minimizeEffect"))
  1099.             {
  1100.                param1.preventDefault();
  1101.                addEventListener(EffectEvent.EFFECT_END,windowMinimizeHandler);
  1102.                dispatchEvent(new Event("windowMinimize"));
  1103.             }
  1104.          }
  1105.          else if(param1.beforeDisplayState == NativeWindowDisplayState.MINIMIZED)
  1106.          {
  1107.             addEventListener(EffectEvent.EFFECT_END,windowUnminimizeHandler);
  1108.             dispatchEvent(new Event("windowUnminimize"));
  1109.          }
  1110.       }
  1111.       
  1112.       private function window_closeEffectEndHandler(param1:Event) : void
  1113.       {
  1114.          removeEventListener(EffectEvent.EFFECT_END,window_closeEffectEndHandler);
  1115.          if(!nativeWindow.closed)
  1116.          {
  1117.             stage.nativeWindow.close();
  1118.          }
  1119.       }
  1120.       
  1121.       protected function set bounds(param1:Rectangle) : void
  1122.       {
  1123.          nativeWindow.bounds = param1;
  1124.          boundsChanged = true;
  1125.          invalidateProperties();
  1126.          invalidateSize();
  1127.          mx_internal::invalidateViewMetricsAndPadding();
  1128.       }
  1129.       
  1130.       public function get closed() : Boolean
  1131.       {
  1132.          return nativeWindow.closed;
  1133.       }
  1134.       
  1135.       public function get autoExit() : Boolean
  1136.       {
  1137.          return nativeApplication.autoExit;
  1138.       }
  1139.       
  1140.       public function set showTitleBar(param1:Boolean) : void
  1141.       {
  1142.          if(_showTitleBar == param1)
  1143.          {
  1144.             return;
  1145.          }
  1146.          _showTitleBar = param1;
  1147.          showTitleBarChanged = true;
  1148.          invalidateProperties();
  1149.          invalidateDisplayList();
  1150.       }
  1151.       
  1152.       private function chromeWidth() : Number
  1153.       {
  1154.          return nativeWindow.width - systemManager.stage.stageWidth;
  1155.       }
  1156.       
  1157.       private function closeButton_clickHandler(param1:Event) : void
  1158.       {
  1159.          stage.nativeWindow.close();
  1160.       }
  1161.       
  1162.       private function viewSourceCloseHandler(param1:Window) : Function
  1163.       {
  1164.          var win:Window = param1;
  1165.          return function():void
  1166.          {
  1167.             win.close();
  1168.          };
  1169.       }
  1170.       
  1171.       private function nativeWindow_activateHandler(param1:Event) : void
  1172.       {
  1173.          dispatchEvent(new AIREvent(AIREvent.WINDOW_ACTIVATE));
  1174.       }
  1175.       
  1176.       override public function set maxWidth(param1:Number) : void
  1177.       {
  1178.          _maxWidth = param1;
  1179.          maxWidthChanged = true;
  1180.          invalidateProperties();
  1181.       }
  1182.       
  1183.       public function get systemChrome() : String
  1184.       {
  1185.          if(nativeWindow.closed)
  1186.          {
  1187.             return "";
  1188.          }
  1189.          return nativeWindow.systemChrome;
  1190.       }
  1191.       
  1192.       override public function validateDisplayList() : void
  1193.       {
  1194.          var _loc1_:Graphics = null;
  1195.          super.validateDisplayList();
  1196.          if(!nativeWindow.closed)
  1197.          {
  1198.             if(Capabilities.os.substring(0,3) == "Mac" && systemChrome == "standard")
  1199.             {
  1200.                if((horizontalScrollBar || verticalScrollBar) && !(Boolean(horizontalScrollBar) && Boolean(verticalScrollBar)) && !showStatusBar)
  1201.                {
  1202.                   if(!whiteBox)
  1203.                   {
  1204.                      whiteBox = new FlexShape();
  1205.                      whiteBox.name = "whiteBox";
  1206.                      _loc1_ = whiteBox.graphics;
  1207.                      _loc1_.beginFill(16777215);
  1208.                      _loc1_.drawRect(0,0,!!verticalScrollBar ? verticalScrollBar.minWidth : 15,!!horizontalScrollBar ? horizontalScrollBar.minHeight : 15);
  1209.                      _loc1_.endFill();
  1210.                      rawChildren.addChild(whiteBox);
  1211.                   }
  1212.                   whiteBox.visible = true;
  1213.                   if(horizontalScrollBar)
  1214.                   {
  1215.                      horizontalScrollBar.setActualSize(horizontalScrollBar.width - whiteBox.width,horizontalScrollBar.height);
  1216.                   }
  1217.                   if(verticalScrollBar)
  1218.                   {
  1219.                      verticalScrollBar.setActualSize(verticalScrollBar.width,verticalScrollBar.height - whiteBox.height);
  1220.                   }
  1221.                   whiteBox.x = systemManager.stage.stageWidth - whiteBox.width;
  1222.                   whiteBox.y = systemManager.stage.stageHeight - whiteBox.height;
  1223.                }
  1224.                else if(!(Boolean(horizontalScrollBar) && Boolean(verticalScrollBar)))
  1225.                {
  1226.                   if(whiteBox)
  1227.                   {
  1228.                      rawChildren.removeChild(whiteBox);
  1229.                      whiteBox = null;
  1230.                   }
  1231.                }
  1232.             }
  1233.             else if(gripper && showGripper && !showStatusBar)
  1234.             {
  1235.                if(whiteBox)
  1236.                {
  1237.                   whiteBox.visible = false;
  1238.                   if(gripperHit.height > whiteBox.height)
  1239.                   {
  1240.                      verticalScrollBar.setActualSize(verticalScrollBar.width,verticalScrollBar.height - (gripperHit.height - whiteBox.height));
  1241.                   }
  1242.                   if(gripperHit.width > whiteBox.width)
  1243.                   {
  1244.                      horizontalScrollBar.setActualSize(horizontalScrollBar.width - (gripperHit.width - whiteBox.height),horizontalScrollBar.height);
  1245.                   }
  1246.                }
  1247.                else if(horizontalScrollBar)
  1248.                {
  1249.                   horizontalScrollBar.setActualSize(horizontalScrollBar.width - gripperHit.width,horizontalScrollBar.height);
  1250.                }
  1251.                else if(verticalScrollBar)
  1252.                {
  1253.                   verticalScrollBar.setActualSize(verticalScrollBar.width,verticalScrollBar.height - gripperHit.height);
  1254.                }
  1255.             }
  1256.             else if(whiteBox)
  1257.             {
  1258.                whiteBox.visible = true;
  1259.             }
  1260.          }
  1261.       }
  1262.       
  1263.       override public function set width(param1:Number) : void
  1264.       {
  1265.          if(param1 < minWidth)
  1266.          {
  1267.             param1 = minWidth;
  1268.          }
  1269.          else if(param1 > maxWidth)
  1270.          {
  1271.             param1 = maxWidth;
  1272.          }
  1273.          _bounds.width = param1;
  1274.          boundsChanged = true;
  1275.          invalidateProperties();
  1276.          invalidateSize();
  1277.          mx_internal::invalidateViewMetricsAndPadding();
  1278.       }
  1279.       
  1280.       public function set dockIconMenu(param1:FlexNativeMenu) : void
  1281.       {
  1282.          _dockIconMenu = param1;
  1283.          if(NativeApplication.supportsDockIcon)
  1284.          {
  1285.             if(nativeApplication.icon is DockIcon)
  1286.             {
  1287.                DockIcon(nativeApplication.icon).menu = param1.nativeMenu;
  1288.             }
  1289.          }
  1290.       }
  1291.       
  1292.       public function get maximizable() : Boolean
  1293.       {
  1294.          if(!nativeWindow.closed)
  1295.          {
  1296.             return nativeWindow.maximizable;
  1297.          }
  1298.          return false;
  1299.       }
  1300.       
  1301.       public function set showGripper(param1:Boolean) : void
  1302.       {
  1303.          if(_showGripper == param1)
  1304.          {
  1305.             return;
  1306.          }
  1307.          _showGripper = param1;
  1308.          showGripperChanged = true;
  1309.          invalidateProperties();
  1310.          invalidateDisplayList();
  1311.       }
  1312.       
  1313.       [Bindable("windowComplete")]
  1314.       [Bindable("maxHeightChanged")]
  1315.       override public function get maxHeight() : Number
  1316.       {
  1317.          if(Boolean(nativeWindow) && !maxHeightChanged)
  1318.          {
  1319.             return nativeWindow.maxSize.y - chromeHeight();
  1320.          }
  1321.          return _maxHeight;
  1322.       }
  1323.       
  1324.       protected function startResize(param1:String) : void
  1325.       {
  1326.          if(!nativeWindow.closed)
  1327.          {
  1328.             if(nativeWindow.resizable)
  1329.             {
  1330.                stage.nativeWindow.startResize(param1);
  1331.             }
  1332.          }
  1333.       }
  1334.       
  1335.       override public function setVisible(param1:Boolean, param2:Boolean = false) : void
  1336.       {
  1337.          if(!_nativeWindow)
  1338.          {
  1339.             _nativeWindowVisible = param1;
  1340.             invalidateProperties();
  1341.          }
  1342.          else if(!_nativeWindow.closed)
  1343.          {
  1344.             if(param1)
  1345.             {
  1346.                _nativeWindow.visible = param1;
  1347.             }
  1348.             else if(getStyle("hideEffect") && initialized && mx_internal::$visible != param1)
  1349.             {
  1350.                addEventListener(EffectEvent.EFFECT_END,hideEffectEndHandler);
  1351.             }
  1352.             else
  1353.             {
  1354.                _nativeWindow.visible = param1;
  1355.             }
  1356.          }
  1357.          super.setVisible(param1,param2);
  1358.       }
  1359.       
  1360.       private function nativeApplication_networkChangeHandler(param1:Event) : void
  1361.       {
  1362.          dispatchEvent(param1);
  1363.       }
  1364.       
  1365.       private function hideEffectEndHandler(param1:Event) : void
  1366.       {
  1367.          if(!_nativeWindow.closed)
  1368.          {
  1369.             _nativeWindow.visible = false;
  1370.          }
  1371.          removeEventListener(EffectEvent.EFFECT_END,hideEffectEndHandler);
  1372.       }
  1373.       
  1374.       override public function styleChanged(param1:String) : void
  1375.       {
  1376.          super.styleChanged(param1);
  1377.          if(!nativeWindow.closed)
  1378.          {
  1379.             if(!(getStyle("showFlexChrome") == "false" || getStyle("showFlexChrome") == false))
  1380.             {
  1381.                if(param1 == null || param1 == "headerHeight" || param1 == "gripperPadding")
  1382.                {
  1383.                   mx_internal::invalidateViewMetricsAndPadding();
  1384.                   invalidateDisplayList();
  1385.                   invalidateSize();
  1386.                }
  1387.             }
  1388.          }
  1389.       }
  1390.       
  1391.       [Bindable("widthChanged")]
  1392.       override public function get width() : Number
  1393.       {
  1394.          return _bounds.width;
  1395.       }
  1396.       
  1397.       override protected function commitProperties() : void
  1398.       {
  1399.          var _loc1_:Number = NaN;
  1400.          var _loc2_:Number = NaN;
  1401.          var _loc3_:Number = NaN;
  1402.          var _loc4_:Number = NaN;
  1403.          var _loc5_:int = 0;
  1404.          super.commitProperties();
  1405.          if(minWidthChanged || minHeightChanged)
  1406.          {
  1407.             _loc1_ = minWidthChanged ? _minWidth + chromeWidth() : Number(nativeWindow.minSize.x);
  1408.             _loc2_ = minHeightChanged ? _minHeight + chromeHeight() : Number(nativeWindow.minSize.y);
  1409.             nativeWindow.minSize = new Point(_loc1_,_loc2_);
  1410.             if(minWidthChanged)
  1411.             {
  1412.                minWidthChanged = false;
  1413.                if(width < minWidth)
  1414.                {
  1415.                   width = minWidth;
  1416.                }
  1417.                dispatchEvent(new Event("minWidthChanged"));
  1418.             }
  1419.             if(minHeightChanged)
  1420.             {
  1421.                minHeightChanged = false;
  1422.                if(height < minHeight)
  1423.                {
  1424.                   height = minHeight;
  1425.                }
  1426.                dispatchEvent(new Event("minHeightChanged"));
  1427.             }
  1428.          }
  1429.          if(maxWidthChanged || maxHeightChanged)
  1430.          {
  1431.             _loc3_ = maxWidthChanged ? _maxWidth + chromeWidth() : Number(nativeWindow.maxSize.x);
  1432.             _loc4_ = maxHeightChanged ? _maxHeight + chromeHeight() : Number(nativeWindow.maxSize.y);
  1433.             nativeWindow.maxSize = new Point(_loc3_,_loc4_);
  1434.             if(maxWidthChanged)
  1435.             {
  1436.                maxWidthChanged = false;
  1437.                if(width > maxWidth)
  1438.                {
  1439.                   width = maxWidth;
  1440.                }
  1441.                dispatchEvent(new Event("maxWidthChanged"));
  1442.             }
  1443.             if(maxHeightChanged)
  1444.             {
  1445.                maxHeightChanged = false;
  1446.                if(height > maxHeight)
  1447.                {
  1448.                   height = maxHeight;
  1449.                }
  1450.                dispatchEvent(new Event("maxHeightChanged"));
  1451.             }
  1452.          }
  1453.          if(boundsChanged)
  1454.          {
  1455.             systemManager.stage.stageWidth = mx_internal::_width = _bounds.width;
  1456.             systemManager.stage.stageHeight = mx_internal::_height = _bounds.height;
  1457.             boundsChanged = false;
  1458.             dispatchEvent(new Event("widthChanged"));
  1459.             dispatchEvent(new Event("heightChanged"));
  1460.          }
  1461.          if(windowBoundsChanged)
  1462.          {
  1463.             _bounds.width = mx_internal::_width = systemManager.stage.stageWidth;
  1464.             _bounds.height = mx_internal::_height = systemManager.stage.stageHeight;
  1465.             windowBoundsChanged = false;
  1466.             dispatchEvent(new Event("widthChanged"));
  1467.             dispatchEvent(new Event("heightChanged"));
  1468.          }
  1469.          if(menuChanged && !nativeWindow.closed)
  1470.          {
  1471.             menuChanged = false;
  1472.             if(menu == null)
  1473.             {
  1474.                if(NativeApplication.supportsMenu)
  1475.                {
  1476.                   nativeApplication.menu = null;
  1477.                }
  1478.                else if(NativeWindow.supportsMenu)
  1479.                {
  1480.                   nativeWindow.menu = null;
  1481.                }
  1482.             }
  1483.             else if(menu.nativeMenu)
  1484.             {
  1485.                if(NativeApplication.supportsMenu)
  1486.                {
  1487.                   nativeApplication.menu = menu.nativeMenu;
  1488.                }
  1489.                else if(NativeWindow.supportsMenu)
  1490.                {
  1491.                   nativeWindow.menu = menu.nativeMenu;
  1492.                }
  1493.             }
  1494.          }
  1495.          if(titleBarFactoryChanged)
  1496.          {
  1497.             if(_titleBar)
  1498.             {
  1499.                rawChildren.removeChild(DisplayObject(titleBar));
  1500.                _titleBar = null;
  1501.             }
  1502.             _titleBar = titleBarFactory.newInstance();
  1503.             _titleBar.styleName = new StyleProxy(this,titleBarStyleFilters);
  1504.             rawChildren.addChild(DisplayObject(titleBar));
  1505.             titleBarFactoryChanged = false;
  1506.             invalidateDisplayList();
  1507.          }
  1508.          if(showTitleBarChanged)
  1509.          {
  1510.             if(titleBar)
  1511.             {
  1512.                titleBar.visible = _showTitleBar;
  1513.             }
  1514.             showTitleBarChanged = false;
  1515.          }
  1516.          if(titleIconChanged)
  1517.          {
  1518.             if(Boolean(_titleBar) && "titleIcon" in _titleBar)
  1519.             {
  1520.                _titleBar["titleIcon"] = _titleIcon;
  1521.             }
  1522.             titleIconChanged = false;
  1523.          }
  1524.          if(titleChanged)
  1525.          {
  1526.             if(!nativeWindow.closed)
  1527.             {
  1528.                systemManager.stage.nativeWindow.title = _title;
  1529.             }
  1530.             if(Boolean(_titleBar) && "title" in _titleBar)
  1531.             {
  1532.                _titleBar["title"] = _title;
  1533.             }
  1534.             titleChanged = false;
  1535.          }
  1536.          if(statusBarFactoryChanged)
  1537.          {
  1538.             if(_statusBar)
  1539.             {
  1540.                rawChildren.removeChild(DisplayObject(_statusBar));
  1541.                _statusBar = null;
  1542.             }
  1543.             _statusBar = statusBarFactory.newInstance();
  1544.             _statusBar.styleName = new StyleProxy(this,statusBarStyleFilters);
  1545.             rawChildren.addChild(DisplayObject(_statusBar));
  1546.             if(gripper)
  1547.             {
  1548.                _loc5_ = int(rawChildren.getChildIndex(DisplayObject(gripper)));
  1549.                rawChildren.setChildIndex(DisplayObject(_statusBar),_loc5_);
  1550.             }
  1551.             statusBarFactoryChanged = false;
  1552.             showStatusBarChanged = true;
  1553.             statusChanged = true;
  1554.             invalidateDisplayList();
  1555.          }
  1556.          if(showStatusBarChanged)
  1557.          {
  1558.             if(_statusBar)
  1559.             {
  1560.                _statusBar.visible = _showStatusBar;
  1561.             }
  1562.             showStatusBarChanged = false;
  1563.          }
  1564.          if(statusChanged)
  1565.          {
  1566.             if(Boolean(_statusBar) && "status" in _statusBar)
  1567.             {
  1568.                _statusBar["status"] = _status;
  1569.             }
  1570.             statusChanged = false;
  1571.          }
  1572.          if(showGripperChanged)
  1573.          {
  1574.             if(gripper)
  1575.             {
  1576.                gripper.visible = _showGripper;
  1577.                gripperHit.visible = _showGripper;
  1578.             }
  1579.             showGripperChanged = false;
  1580.          }
  1581.          if(toMax)
  1582.          {
  1583.             toMax = false;
  1584.             if(!nativeWindow.closed)
  1585.             {
  1586.                nativeWindow.maximize();
  1587.             }
  1588.          }
  1589.       }
  1590.       
  1591.       override public function move(param1:Number, param2:Number) : void
  1592.       {
  1593.          var _loc3_:Rectangle = null;
  1594.          if(Boolean(nativeWindow) && !nativeWindow.closed)
  1595.          {
  1596.             _loc3_ = nativeWindow.bounds;
  1597.             _loc3_.x = param1;
  1598.             _loc3_.y = param2;
  1599.             nativeWindow.bounds = _loc3_;
  1600.          }
  1601.       }
  1602.       
  1603.       public function set titleBarFactory(param1:IFactory) : void
  1604.       {
  1605.          _titleBarFactory = param1;
  1606.          titleBarFactoryChanged = true;
  1607.          invalidateProperties();
  1608.          dispatchEvent(new Event("titleBarFactoryChanged"));
  1609.       }
  1610.       
  1611.       private function window_resizeHandler(param1:NativeWindowBoundsEvent) : void
  1612.       {
  1613.          if(!windowBoundsChanged)
  1614.          {
  1615.             windowBoundsChanged = true;
  1616.             invalidateProperties();
  1617.             mx_internal::invalidateViewMetricsAndPadding();
  1618.             invalidateDisplayList();
  1619.             validateNow();
  1620.          }
  1621.          var _loc2_:FlexNativeWindowBoundsEvent = new FlexNativeWindowBoundsEvent(FlexNativeWindowBoundsEvent.WINDOW_RESIZE,param1.bubbles,param1.cancelable,param1.beforeBounds,param1.afterBounds);
  1622.          dispatchEvent(_loc2_);
  1623.       }
  1624.       
  1625.       public function set titleIcon(param1:Class) : void
  1626.       {
  1627.          _titleIcon = param1;
  1628.          titleIconChanged = true;
  1629.          invalidateProperties();
  1630.          invalidateSize();
  1631.          mx_internal::invalidateViewMetricsAndPadding();
  1632.          invalidateDisplayList();
  1633.          dispatchEvent(new Event("titleIconChanged"));
  1634.       }
  1635.       
  1636.       public function set alwaysInFront(param1:Boolean) : void
  1637.       {
  1638.          _alwaysInFront = param1;
  1639.          if(Boolean(_nativeWindow) && !_nativeWindow.closed)
  1640.          {
  1641.             nativeWindow.alwaysInFront = param1;
  1642.          }
  1643.       }
  1644.       
  1645.       public function set status(param1:String) : void
  1646.       {
  1647.          _status = param1;
  1648.          statusChanged = true;
  1649.          invalidateProperties();
  1650.          invalidateSize();
  1651.          mx_internal::invalidateViewMetricsAndPadding();
  1652.          dispatchEvent(new Event("statusChanged"));
  1653.       }
  1654.       
  1655.       private function stage_fullScreenHandler(param1:FullScreenEvent) : void
  1656.       {
  1657.          if(stage.displayState != lastDisplayState)
  1658.          {
  1659.             lastDisplayState = stage.displayState;
  1660.             if(stage.displayState == StageDisplayState.FULL_SCREEN || stage.displayState == StageDisplayState.FULL_SCREEN_INTERACTIVE)
  1661.             {
  1662.                shouldShowTitleBar = showTitleBar;
  1663.                showTitleBar = false;
  1664.             }
  1665.             else
  1666.             {
  1667.                showTitleBar = shouldShowTitleBar;
  1668.             }
  1669.          }
  1670.       }
  1671.       
  1672.       [Bindable("titleBarFactoryChanged")]
  1673.       public function get titleBarFactory() : IFactory
  1674.       {
  1675.          return _titleBarFactory;
  1676.       }
  1677.       
  1678.       [Bindable("statusChanged")]
  1679.       public function get status() : String
  1680.       {
  1681.          return _status;
  1682.       }
  1683.       
  1684.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  1685.       {
  1686.          var _loc3_:EdgeMetrics = null;
  1687.          var _loc4_:Number = NaN;
  1688.          var _loc5_:Number = NaN;
  1689.          var _loc6_:String = null;
  1690.          if(!nativeWindow.closed)
  1691.          {
  1692.             super.updateDisplayList(param1,param2);
  1693.             _loc3_ = borderMetrics;
  1694.             _loc4_ = 10;
  1695.             _loc5_ = 10;
  1696.             if(_statusBar)
  1697.             {
  1698.                _statusBar.move(_loc3_.left,param2 - _loc3_.bottom - getStatusBarHeight());
  1699.                _statusBar.setActualSize(param1 - _loc3_.left - _loc3_.right,getStatusBarHeight());
  1700.             }
  1701.             if(systemManager.stage.nativeWindow.systemChrome != "none" || Boolean(systemManager.stage.nativeWindow.closed))
  1702.             {
  1703.                return;
  1704.             }
  1705.             _loc6_ = String(getStyle("buttonAlignment"));
  1706.             if(titleBar)
  1707.             {
  1708.                titleBar.move(_loc3_.left,_loc3_.top);
  1709.                titleBar.setActualSize(param1 - _loc3_.left - _loc3_.right,getHeaderHeight());
  1710.             }
  1711.             if(Boolean(titleBar) && Boolean(controlBar))
  1712.             {
  1713.                controlBar.move(0,titleBar.height);
  1714.             }
  1715.             if(Boolean(gripper) && showGripper)
  1716.             {
  1717.                _gripperPadding = getStyle("gripperPadding");
  1718.                gripper.setActualSize(gripper.measuredWidth,gripper.measuredHeight);
  1719.                gripperHit.graphics.beginFill(16777215,0.0001);
  1720.                gripperHit.graphics.drawRect(0,0,gripper.width + 2 * _gripperPadding,gripper.height + 2 * _gripperPadding);
  1721.                gripper.move(param1 - gripper.measuredWidth - _gripperPadding,param2 - gripper.measuredHeight - _gripperPadding);
  1722.                gripperHit.x = gripper.x - _gripperPadding;
  1723.                gripperHit.y = gripper.y - _gripperPadding;
  1724.             }
  1725.          }
  1726.       }
  1727.       
  1728.       public function close() : void
  1729.       {
  1730.          var _loc1_:Event = null;
  1731.          if(!nativeWindow.closed)
  1732.          {
  1733.             _loc1_ = new Event("closing",true,true);
  1734.             stage.nativeWindow.dispatchEvent(_loc1_);
  1735.             if(!_loc1_.isDefaultPrevented())
  1736.             {
  1737.                stage.nativeWindow.close();
  1738.             }
  1739.          }
  1740.       }
  1741.    }
  1742. }
  1743.  
  1744.