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

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