home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2012 April / ME_04_2012.iso / Video-Tutorial / iPhoto / media / player.swf / scripts / mx / containers / DividedBox.as < prev    next >
Encoding:
Text File  |  2011-11-11  |  31.0 KB  |  922 lines

  1. package mx.containers
  2. {
  3.    import flash.display.DisplayObject;
  4.    import flash.events.Event;
  5.    import flash.events.MouseEvent;
  6.    import flash.geom.Point;
  7.    import mx.containers.dividedBoxClasses.BoxDivider;
  8.    import mx.core.EdgeMetrics;
  9.    import mx.core.IFlexDisplayObject;
  10.    import mx.core.IFlexModuleFactory;
  11.    import mx.core.IInvalidating;
  12.    import mx.core.IUIComponent;
  13.    import mx.core.UIComponent;
  14.    import mx.core.mx_internal;
  15.    import mx.events.ChildExistenceChangedEvent;
  16.    import mx.events.DividerEvent;
  17.    import mx.managers.CursorManager;
  18.    import mx.managers.CursorManagerPriority;
  19.    
  20.    use namespace mx_internal;
  21.    
  22.    public class DividedBox extends Box
  23.    {
  24.       mx_internal static const VERSION:String = "4.5.0.20967";
  25.       
  26.       private static const PROXY_DIVIDER_INDEX:int = 999;
  27.       
  28.       private var dividerLayer:UIComponent = null;
  29.       
  30.       mx_internal var activeDivider:BoxDivider;
  31.       
  32.       private var activeDividerIndex:int = -1;
  33.       
  34.       private var activeDividerStartPosition:Number;
  35.       
  36.       private var dragStartPosition:Number;
  37.       
  38.       private var dragDelta:Number;
  39.       
  40.       private var oldChildSizes:Array;
  41.       
  42.       private var minDelta:Number;
  43.       
  44.       private var maxDelta:Number;
  45.       
  46.       private var dontCoalesceDividers:Boolean;
  47.       
  48.       private var cursorID:int = 0;
  49.       
  50.       private var dbMinWidth:Number;
  51.       
  52.       private var dbMinHeight:Number;
  53.       
  54.       private var dbPreferredWidth:Number;
  55.       
  56.       private var dbPreferredHeight:Number;
  57.       
  58.       private var layoutStyleChanged:Boolean = false;
  59.       
  60.       private var _resizeToContent:Boolean = false;
  61.       
  62.       private var numLayoutChildren:int = 0;
  63.       
  64.       protected var dividerClass:Class = BoxDivider;
  65.       
  66.       public var liveDragging:Boolean = false;
  67.       
  68.       private var postLayoutChanges:Array;
  69.       
  70.       public function DividedBox()
  71.       {
  72.          super();
  73.          addEventListener(ChildExistenceChangedEvent.CHILD_ADD,this.childAddHandler);
  74.          addEventListener(ChildExistenceChangedEvent.CHILD_REMOVE,this.childRemoveHandler);
  75.          showInAutomationHierarchy = true;
  76.       }
  77.       
  78.       override public function set moduleFactory(param1:IFlexModuleFactory) : void
  79.       {
  80.          super.moduleFactory = param1;
  81.          styleManager.registerSizeInvalidatingStyle("dividerAffordance");
  82.          styleManager.registerSizeInvalidatingStyle("dividerThickness");
  83.       }
  84.       
  85.       override public function set direction(param1:String) : void
  86.       {
  87.          var _loc2_:int = 0;
  88.          if(super.direction != param1)
  89.          {
  90.             super.direction = param1;
  91.             if(this.dividerLayer)
  92.             {
  93.                _loc2_ = 0;
  94.                while(_loc2_ < this.dividerLayer.numChildren)
  95.                {
  96.                   this.getDividerAt(_loc2_).invalidateDisplayList();
  97.                   _loc2_++;
  98.                }
  99.             }
  100.          }
  101.       }
  102.       
  103.       public function get numDividers() : int
  104.       {
  105.          if(this.dividerLayer)
  106.          {
  107.             if(!this.liveDragging && Boolean(this.mx_internal::activeDivider))
  108.             {
  109.                return this.dividerLayer.numChildren - 1;
  110.             }
  111.             return this.dividerLayer.numChildren;
  112.          }
  113.          return 0;
  114.       }
  115.       
  116.       public function get resizeToContent() : Boolean
  117.       {
  118.          return this._resizeToContent;
  119.       }
  120.       
  121.       public function set resizeToContent(param1:Boolean) : void
  122.       {
  123.          if(param1 != this._resizeToContent)
  124.          {
  125.             this._resizeToContent = param1;
  126.             if(param1)
  127.             {
  128.                invalidateSize();
  129.             }
  130.          }
  131.       }
  132.       
  133.       override protected function measure() : void
  134.       {
  135.          var _loc8_:Number = NaN;
  136.          var _loc9_:Number = NaN;
  137.          var _loc10_:IUIComponent = null;
  138.          var _loc11_:Number = NaN;
  139.          var _loc12_:Number = NaN;
  140.          var _loc13_:Number = NaN;
  141.          var _loc14_:Number = NaN;
  142.          var _loc15_:* = false;
  143.          var _loc16_:* = false;
  144.          var _loc17_:Number = NaN;
  145.          var _loc18_:Number = NaN;
  146.          super.measure();
  147.          if(!isNaN(this.dbPreferredWidth) && !this._resizeToContent && !this.layoutStyleChanged)
  148.          {
  149.             measuredMinWidth = this.dbMinWidth;
  150.             measuredMinHeight = this.dbMinHeight;
  151.             measuredWidth = this.dbPreferredWidth;
  152.             measuredHeight = this.dbPreferredHeight;
  153.             return;
  154.          }
  155.          this.layoutStyleChanged = false;
  156.          var _loc1_:Boolean = Boolean(this.mx_internal::isVertical());
  157.          var _loc2_:Number = 0;
  158.          var _loc3_:Number = 0;
  159.          var _loc4_:Number = 0;
  160.          var _loc5_:Number = 0;
  161.          var _loc6_:int = numChildren;
  162.          var _loc7_:int = 0;
  163.          while(_loc7_ < _loc6_)
  164.          {
  165.             _loc10_ = mx_internal::getLayoutChildAt(_loc7_);
  166.             if(_loc10_.includeInLayout)
  167.             {
  168.                _loc11_ = Number(_loc10_.getExplicitOrMeasuredWidth());
  169.                _loc12_ = Number(_loc10_.getExplicitOrMeasuredHeight());
  170.                _loc13_ = Number(_loc10_.minWidth);
  171.                _loc14_ = Number(_loc10_.minHeight);
  172.                _loc15_ = !isNaN(_loc10_.percentWidth);
  173.                _loc16_ = !isNaN(_loc10_.percentHeight);
  174.                _loc17_ = Math.min(_loc11_,_loc13_);
  175.                _loc18_ = Math.min(_loc12_,_loc14_);
  176.                if(_loc1_)
  177.                {
  178.                   _loc2_ = Math.max(_loc15_ ? _loc13_ : _loc11_,_loc2_);
  179.                   _loc4_ = Math.max(_loc11_,_loc4_);
  180.                   _loc3_ += _loc16_ ? _loc18_ : _loc12_;
  181.                   _loc5_ += _loc12_;
  182.                }
  183.                else
  184.                {
  185.                   _loc2_ += _loc15_ ? _loc17_ : _loc11_;
  186.                   _loc4_ += _loc11_;
  187.                   _loc3_ = Math.max(_loc16_ ? _loc14_ : _loc12_,_loc3_);
  188.                   _loc5_ = Math.max(_loc12_,_loc5_);
  189.                }
  190.             }
  191.             _loc7_++;
  192.          }
  193.          _loc8_ = Number(mx_internal::layoutObject.mx_internal::widthPadding(this.numLayoutChildren));
  194.          _loc9_ = Number(mx_internal::layoutObject.mx_internal::heightPadding(this.numLayoutChildren));
  195.          measuredMinWidth = this.dbMinWidth = _loc2_ + _loc8_;
  196.          measuredMinHeight = this.dbMinHeight = _loc3_ + _loc9_;
  197.          measuredWidth = this.dbPreferredWidth = _loc4_ + _loc8_;
  198.          measuredHeight = this.dbPreferredHeight = _loc5_ + _loc9_;
  199.       }
  200.       
  201.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  202.       {
  203.          var _loc3_:int = 0;
  204.          var _loc4_:int = 0;
  205.          var _loc8_:IUIComponent = null;
  206.          if(!this.liveDragging && Boolean(this.mx_internal::activeDivider))
  207.          {
  208.             _loc3_ = numChildren;
  209.             _loc4_ = 0;
  210.             while(_loc4_ < _loc3_)
  211.             {
  212.                _loc8_ = mx_internal::getLayoutChildAt(_loc4_);
  213.                if(_loc8_.includeInLayout)
  214.                {
  215.                   _loc8_.measuredMinWidth = 0;
  216.                   _loc8_.measuredMinHeight = 0;
  217.                }
  218.                _loc4_++;
  219.             }
  220.             return;
  221.          }
  222.          this.preLayoutAdjustment();
  223.          super.updateDisplayList(param1,param2);
  224.          this.postLayoutAdjustment();
  225.          if(!this.dividerLayer)
  226.          {
  227.             return;
  228.          }
  229.          var _loc5_:EdgeMetrics = viewMetrics;
  230.          this.dividerLayer.x = _loc5_.left;
  231.          this.dividerLayer.y = _loc5_.top;
  232.          var _loc6_:IUIComponent = null;
  233.          var _loc7_:int = 0;
  234.          _loc3_ = numChildren;
  235.          _loc4_ = 0;
  236.          while(_loc4_ < _loc3_)
  237.          {
  238.             _loc8_ = UIComponent(getChildAt(_loc4_));
  239.             if(_loc8_.includeInLayout)
  240.             {
  241.                if(_loc6_)
  242.                {
  243.                   this.layoutDivider(_loc7_,param1,param2,_loc6_,_loc8_);
  244.                   _loc7_++;
  245.                }
  246.                _loc6_ = _loc8_;
  247.             }
  248.             _loc4_++;
  249.          }
  250.       }
  251.       
  252.       override public function styleChanged(param1:String) : void
  253.       {
  254.          var _loc2_:int = 0;
  255.          var _loc3_:int = 0;
  256.          super.styleChanged(param1);
  257.          if(this.dividerLayer)
  258.          {
  259.             _loc2_ = this.dividerLayer.numChildren;
  260.             _loc3_ = 0;
  261.             while(_loc3_ < _loc2_)
  262.             {
  263.                this.getDividerAt(_loc3_).styleChanged(param1);
  264.                _loc3_++;
  265.             }
  266.          }
  267.          if(styleManager.isSizeInvalidatingStyle(param1))
  268.          {
  269.             this.layoutStyleChanged = true;
  270.          }
  271.       }
  272.       
  273.       override protected function scrollChildren() : void
  274.       {
  275.          super.scrollChildren();
  276.          if(Boolean(mx_internal::contentPane) && Boolean(this.dividerLayer))
  277.          {
  278.             this.dividerLayer.scrollRect = mx_internal::contentPane.scrollRect;
  279.          }
  280.       }
  281.       
  282.       public function getDividerAt(param1:int) : BoxDivider
  283.       {
  284.          return BoxDivider(this.dividerLayer.getChildAt(param1));
  285.       }
  286.       
  287.       public function moveDivider(param1:int, param2:Number) : void
  288.       {
  289.          if(param1 < 0 || param1 >= this.numDividers)
  290.          {
  291.             return;
  292.          }
  293.          if(this.activeDividerIndex >= 0)
  294.          {
  295.             return;
  296.          }
  297.          this.activeDividerIndex = param1;
  298.          this.cacheChildSizes();
  299.          this.computeMinAndMaxDelta();
  300.          this.dragDelta = this.limitDelta(param2);
  301.          this.adjustChildSizes();
  302.          invalidateSize();
  303.          invalidateDisplayList();
  304.          this.resetDividerTracking();
  305.       }
  306.       
  307.       private function createDivider(param1:int) : BoxDivider
  308.       {
  309.          if(!this.dividerLayer)
  310.          {
  311.             this.dividerLayer = UIComponent(rawChildren.addChild(new UIComponent()));
  312.          }
  313.          var _loc2_:BoxDivider = BoxDivider(new this.dividerClass());
  314.          this.dividerLayer.addChild(_loc2_);
  315.          if(param1 == PROXY_DIVIDER_INDEX)
  316.          {
  317.             rawChildren.setChildIndex(this.dividerLayer,rawChildren.numChildren - 1);
  318.          }
  319.          var _loc3_:IFlexDisplayObject = param1 == PROXY_DIVIDER_INDEX ? this.getDividerAt(this.activeDividerIndex) : this;
  320.          _loc2_.styleName = _loc3_;
  321.          _loc2_.owner = this;
  322.          return _loc2_;
  323.       }
  324.       
  325.       private function layoutDivider(param1:int, param2:Number, param3:Number, param4:IUIComponent, param5:IUIComponent) : void
  326.       {
  327.          var _loc12_:Number = NaN;
  328.          var _loc13_:Number = NaN;
  329.          var _loc6_:BoxDivider = BoxDivider(this.getDividerAt(param1));
  330.          var _loc7_:EdgeMetrics = viewMetrics;
  331.          var _loc8_:Number = getStyle("verticalGap");
  332.          var _loc9_:Number = getStyle("horizontalGap");
  333.          var _loc10_:Number = _loc6_.getStyle("dividerThickness");
  334.          var _loc11_:Number = _loc6_.getStyle("dividerAffordance");
  335.          if(mx_internal::isVertical())
  336.          {
  337.             _loc12_ = _loc11_;
  338.             if(_loc12_ < _loc10_)
  339.             {
  340.                _loc12_ = _loc10_;
  341.             }
  342.             if(_loc12_ > _loc8_)
  343.             {
  344.                _loc12_ = _loc8_;
  345.             }
  346.             _loc6_.setActualSize(param2 - _loc7_.left - _loc7_.right,_loc12_);
  347.             _loc6_.move(_loc7_.left,Math.round((param4.y + param4.height + param5.y - _loc12_) / 2));
  348.          }
  349.          else
  350.          {
  351.             _loc13_ = _loc11_;
  352.             if(_loc13_ < _loc10_)
  353.             {
  354.                _loc13_ = _loc10_;
  355.             }
  356.             if(_loc13_ > _loc9_)
  357.             {
  358.                _loc13_ = _loc9_;
  359.             }
  360.             _loc6_.setActualSize(_loc13_,param3 - _loc7_.top - _loc7_.bottom);
  361.             _loc6_.move(Math.round((param4.x + param4.width + param5.x - _loc13_) / 2),_loc7_.top);
  362.          }
  363.          _loc6_.invalidateDisplayList();
  364.       }
  365.       
  366.       mx_internal function changeCursor(param1:BoxDivider) : void
  367.       {
  368.          var _loc2_:Class = null;
  369.          if(this.cursorID == CursorManager.NO_CURSOR)
  370.          {
  371.             _loc2_ = !!mx_internal::isVertical() ? getStyle("verticalDividerCursor") as Class : getStyle("horizontalDividerCursor") as Class;
  372.             this.cursorID = cursorManager.setCursor(_loc2_,CursorManagerPriority.HIGH,0,0);
  373.          }
  374.       }
  375.       
  376.       mx_internal function restoreCursor() : void
  377.       {
  378.          if(this.cursorID != CursorManager.NO_CURSOR)
  379.          {
  380.             cursorManager.removeCursor(this.cursorID);
  381.             this.cursorID = CursorManager.NO_CURSOR;
  382.          }
  383.       }
  384.       
  385.       mx_internal function getDividerIndex(param1:BoxDivider) : int
  386.       {
  387.          var _loc2_:int = numChildren;
  388.          var _loc3_:int = 0;
  389.          while(_loc3_ < _loc2_ - 1)
  390.          {
  391.             if(this.getDividerAt(_loc3_) == param1)
  392.             {
  393.                return _loc3_;
  394.             }
  395.             _loc3_++;
  396.          }
  397.          return -1;
  398.       }
  399.       
  400.       private function getMousePosition(param1:MouseEvent) : Number
  401.       {
  402.          var _loc2_:Point = new Point(param1.stageX,param1.stageY);
  403.          _loc2_ = globalToLocal(_loc2_);
  404.          return !!mx_internal::isVertical() ? _loc2_.y : _loc2_.x;
  405.       }
  406.       
  407.       mx_internal function startDividerDrag(param1:BoxDivider, param2:MouseEvent) : void
  408.       {
  409.          if(this.activeDividerIndex >= 0)
  410.          {
  411.             return;
  412.          }
  413.          this.activeDividerIndex = this.mx_internal::getDividerIndex(param1);
  414.          var _loc3_:DividerEvent = new DividerEvent(DividerEvent.DIVIDER_PRESS);
  415.          _loc3_.dividerIndex = this.activeDividerIndex;
  416.          dispatchEvent(_loc3_);
  417.          if(this.liveDragging)
  418.          {
  419.             this.mx_internal::activeDivider = param1;
  420.          }
  421.          else
  422.          {
  423.             this.mx_internal::activeDivider = this.createDivider(PROXY_DIVIDER_INDEX);
  424.             this.mx_internal::activeDivider.visible = false;
  425.             this.mx_internal::activeDivider.mx_internal::state = DividerState.DOWN;
  426.             this.mx_internal::activeDivider.setActualSize(param1.width,param1.height);
  427.             this.mx_internal::activeDivider.move(param1.x,param1.y);
  428.             this.mx_internal::activeDivider.visible = true;
  429.             param1.mx_internal::state = DividerState.UP;
  430.          }
  431.          if(mx_internal::isVertical())
  432.          {
  433.             this.activeDividerStartPosition = this.mx_internal::activeDivider.y;
  434.          }
  435.          else
  436.          {
  437.             this.activeDividerStartPosition = this.mx_internal::activeDivider.x;
  438.          }
  439.          this.dragStartPosition = this.getMousePosition(param2);
  440.          this.dragDelta = 0;
  441.          this.cacheChildSizes();
  442.          this.adjustChildSizes();
  443.          this.computeMinAndMaxDelta();
  444.          systemManager.getSandboxRoot().addEventListener(MouseEvent.MOUSE_MOVE,this.mouseMoveHandler,true);
  445.          systemManager.deployMouseShields(true);
  446.       }
  447.       
  448.       private function cacheSizes() : void
  449.       {
  450.          var _loc5_:IUIComponent = null;
  451.          var _loc6_:Number = NaN;
  452.          var _loc7_:Number = NaN;
  453.          var _loc8_:Number = NaN;
  454.          var _loc9_:Number = NaN;
  455.          var _loc10_:Number = NaN;
  456.          var _loc11_:Number = NaN;
  457.          this.oldChildSizes = [];
  458.          var _loc1_:Boolean = Boolean(mx_internal::isVertical());
  459.          var _loc2_:Number = Number.MAX_VALUE;
  460.          var _loc3_:int = numChildren;
  461.          var _loc4_:int = 0;
  462.          while(_loc4_ < _loc3_)
  463.          {
  464.             _loc5_ = mx_internal::getLayoutChildAt(_loc4_);
  465.             if(_loc5_.includeInLayout)
  466.             {
  467.                _loc6_ = _loc1_ ? Number(_loc5_.height) : Number(_loc5_.width);
  468.                _loc7_ = _loc1_ ? Number(_loc5_.maxHeight) : Number(_loc5_.maxWidth);
  469.                _loc8_ = _loc1_ ? Number(_loc5_.explicitMinHeight) : Number(_loc5_.explicitMinWidth);
  470.                _loc9_ = isNaN(_loc8_) ? 0 : _loc8_;
  471.                _loc10_ = Math.max(0,_loc6_ - _loc9_);
  472.                _loc11_ = Math.max(0,_loc7_ - _loc6_);
  473.                if(_loc6_ > 0 && _loc6_ < _loc2_)
  474.                {
  475.                   _loc2_ = _loc6_;
  476.                }
  477.                this.oldChildSizes.push(new ChildSizeInfo(_loc6_,_loc9_,_loc7_,_loc10_,_loc11_));
  478.             }
  479.             _loc4_++;
  480.          }
  481.          this.oldChildSizes.push(new ChildSizeInfo(_loc2_ == Number.MAX_VALUE ? 1 : _loc2_));
  482.       }
  483.       
  484.       private function cacheChildSizes() : void
  485.       {
  486.          this.oldChildSizes = [];
  487.          this.cacheSizes();
  488.       }
  489.       
  490.       private function mouseMoveHandler(param1:MouseEvent) : void
  491.       {
  492.          this.dragDelta = this.limitDelta(this.getMousePosition(param1) - this.dragStartPosition);
  493.          var _loc2_:DividerEvent = new DividerEvent(DividerEvent.DIVIDER_DRAG);
  494.          _loc2_.dividerIndex = this.activeDividerIndex;
  495.          _loc2_.delta = this.dragDelta;
  496.          dispatchEvent(_loc2_);
  497.          if(this.liveDragging)
  498.          {
  499.             this.adjustChildSizes();
  500.             invalidateDisplayList();
  501.             this.updateDisplayList(unscaledWidth,unscaledHeight);
  502.          }
  503.          else if(mx_internal::isVertical())
  504.          {
  505.             this.mx_internal::activeDivider.move(0,this.activeDividerStartPosition + this.dragDelta);
  506.          }
  507.          else
  508.          {
  509.             this.mx_internal::activeDivider.move(this.activeDividerStartPosition + this.dragDelta,0);
  510.          }
  511.       }
  512.       
  513.       mx_internal function stopDividerDrag(param1:BoxDivider, param2:MouseEvent) : void
  514.       {
  515.          if(param2)
  516.          {
  517.             this.dragDelta = this.limitDelta(this.getMousePosition(param2) - this.dragStartPosition);
  518.          }
  519.          var _loc3_:DividerEvent = new DividerEvent(DividerEvent.DIVIDER_RELEASE);
  520.          _loc3_.dividerIndex = this.activeDividerIndex;
  521.          _loc3_.delta = this.dragDelta;
  522.          dispatchEvent(_loc3_);
  523.          if(!this.liveDragging)
  524.          {
  525.             if(this.dragDelta == 0)
  526.             {
  527.                this.getDividerAt(this.activeDividerIndex).mx_internal::state = DividerState.OVER;
  528.             }
  529.             if(this.mx_internal::activeDivider)
  530.             {
  531.                this.dividerLayer.removeChild(this.mx_internal::activeDivider);
  532.             }
  533.             this.mx_internal::activeDivider = null;
  534.             this.adjustChildSizes();
  535.             invalidateSize();
  536.             invalidateDisplayList();
  537.          }
  538.          this.resetDividerTracking();
  539.          systemManager.getSandboxRoot().removeEventListener(MouseEvent.MOUSE_MOVE,this.mouseMoveHandler,true);
  540.          systemManager.deployMouseShields(false);
  541.       }
  542.       
  543.       private function resetDividerTracking() : void
  544.       {
  545.          this.mx_internal::activeDivider = null;
  546.          this.activeDividerIndex = -1;
  547.          this.activeDividerStartPosition = NaN;
  548.          this.dragStartPosition = NaN;
  549.          this.dragDelta = NaN;
  550.          this.oldChildSizes = null;
  551.          this.minDelta = NaN;
  552.          this.maxDelta = NaN;
  553.       }
  554.       
  555.       private function computeAllowableMovement(param1:int) : void
  556.       {
  557.          var _loc7_:int = 0;
  558.          var _loc8_:ChildSizeInfo = null;
  559.          var _loc2_:Number = 0;
  560.          var _loc3_:Number = 0;
  561.          var _loc4_:Number = 0;
  562.          var _loc5_:Number = 0;
  563.          var _loc6_:int = this.numLayoutChildren;
  564.          if(param1 < 0)
  565.          {
  566.             return;
  567.          }
  568.          _loc7_ = param1;
  569.          while(_loc7_ >= 0)
  570.          {
  571.             _loc8_ = ChildSizeInfo(this.oldChildSizes[_loc7_]);
  572.             _loc2_ += this.dontCoalesceDividers && Boolean(_loc2_) ? 0 : _loc8_.deltaMin;
  573.             _loc3_ += this.dontCoalesceDividers && Boolean(_loc3_) ? 0 : _loc8_.deltaMax;
  574.             _loc7_--;
  575.          }
  576.          _loc7_ = param1 + 1;
  577.          while(_loc7_ < _loc6_)
  578.          {
  579.             _loc8_ = ChildSizeInfo(this.oldChildSizes[_loc7_]);
  580.             _loc4_ += this.dontCoalesceDividers && Boolean(_loc4_) ? 0 : _loc8_.deltaMin;
  581.             _loc5_ += this.dontCoalesceDividers && Boolean(_loc5_) ? 0 : _loc8_.deltaMax;
  582.             _loc7_++;
  583.          }
  584.          var _loc9_:Number = Math.min(_loc2_,_loc5_);
  585.          var _loc10_:Number = Math.min(_loc4_,_loc3_);
  586.          this.minDelta = -_loc9_;
  587.          this.maxDelta = _loc10_;
  588.       }
  589.       
  590.       private function computeMinAndMaxDelta() : void
  591.       {
  592.          this.computeAllowableMovement(this.activeDividerIndex);
  593.       }
  594.       
  595.       private function limitDelta(param1:Number) : Number
  596.       {
  597.          if(param1 < this.minDelta)
  598.          {
  599.             param1 = this.minDelta;
  600.          }
  601.          else if(param1 > this.maxDelta)
  602.          {
  603.             param1 = this.maxDelta;
  604.          }
  605.          return Math.round(param1);
  606.       }
  607.       
  608.       private function distributeDelta() : void
  609.       {
  610.          var _loc5_:int = 0;
  611.          var _loc6_:ChildSizeInfo = null;
  612.          var _loc7_:Number = NaN;
  613.          var _loc8_:Number = NaN;
  614.          var _loc9_:IUIComponent = null;
  615.          var _loc10_:Number = NaN;
  616.          if(!this.dragDelta)
  617.          {
  618.             return;
  619.          }
  620.          var _loc1_:Boolean = Boolean(mx_internal::isVertical());
  621.          var _loc2_:int = this.numLayoutChildren;
  622.          var _loc3_:int = this.activeDividerIndex;
  623.          var _loc4_:Number = this.oldChildSizes[_loc2_].size - Math.abs(this.dragDelta);
  624.          if(_loc4_ <= 0 || isNaN(_loc4_))
  625.          {
  626.             _loc4_ = 1;
  627.          }
  628.          var _loc11_:int = -1;
  629.          var _loc12_:int = -1;
  630.          while(_loc12_ < this.activeDividerIndex)
  631.          {
  632.             if(UIComponent(getChildAt(++_loc11_)).includeInLayout)
  633.             {
  634.                _loc12_++;
  635.             }
  636.          }
  637.          var _loc13_:int = _loc11_;
  638.          var _loc14_:Number = this.dragDelta;
  639.          _loc5_ = _loc3_;
  640.          while(_loc5_ >= 0)
  641.          {
  642.             _loc6_ = ChildSizeInfo(this.oldChildSizes[_loc5_]);
  643.             _loc7_ = _loc14_ < 0 ? -Math.min(-_loc14_,_loc6_.deltaMin) : Math.min(_loc14_,_loc6_.deltaMax);
  644.             _loc8_ = _loc6_.size + _loc7_;
  645.             _loc14_ -= _loc7_;
  646.             while(true)
  647.             {
  648.                _loc9_ = IUIComponent(getChildAt(_loc13_--));
  649.                if(_loc9_.includeInLayout)
  650.                {
  651.                   break;
  652.                }
  653.             }
  654.             _loc10_ = _loc8_ / _loc4_ * 100;
  655.             if(_loc1_)
  656.             {
  657.                _loc9_.percentHeight = _loc10_;
  658.             }
  659.             else
  660.             {
  661.                _loc9_.percentWidth = _loc10_;
  662.             }
  663.             if(_loc9_ is IInvalidating)
  664.             {
  665.                IInvalidating(_loc9_).invalidateSize();
  666.             }
  667.             _loc5_--;
  668.          }
  669.          _loc13_ = _loc11_ + 1;
  670.          _loc14_ = this.dragDelta;
  671.          _loc5_ = _loc3_ + 1;
  672.          while(_loc5_ < _loc2_)
  673.          {
  674.             _loc6_ = ChildSizeInfo(this.oldChildSizes[_loc5_]);
  675.             _loc7_ = _loc14_ < 0 ? Math.min(-_loc14_,_loc6_.deltaMax) : -Math.min(_loc14_,_loc6_.deltaMin);
  676.             _loc8_ = _loc6_.size + _loc7_;
  677.             _loc14_ += _loc7_;
  678.             while(true)
  679.             {
  680.                _loc9_ = IUIComponent(getChildAt(_loc13_++));
  681.                if(_loc9_.includeInLayout)
  682.                {
  683.                   break;
  684.                }
  685.             }
  686.             _loc10_ = _loc8_ / _loc4_ * 100;
  687.             if(_loc1_)
  688.             {
  689.                _loc9_.percentHeight = _loc10_;
  690.             }
  691.             else
  692.             {
  693.                _loc9_.percentWidth = _loc10_;
  694.             }
  695.             if(_loc9_ is IInvalidating)
  696.             {
  697.                IInvalidating(_loc9_).invalidateSize();
  698.             }
  699.             _loc5_++;
  700.          }
  701.       }
  702.       
  703.       private function adjustChildSizes() : void
  704.       {
  705.          this.distributeDelta();
  706.       }
  707.       
  708.       private function preLayoutAdjustment() : void
  709.       {
  710.          var _loc5_:int = 0;
  711.          var _loc6_:IUIComponent = null;
  712.          var _loc7_:Number = NaN;
  713.          var _loc8_:Object = null;
  714.          var _loc9_:Number = NaN;
  715.          var _loc1_:Boolean = Boolean(mx_internal::isVertical());
  716.          var _loc2_:Number = 0;
  717.          var _loc3_:Number = 0;
  718.          var _loc4_:int = numChildren;
  719.          _loc5_ = 0;
  720.          while(_loc5_ < _loc4_)
  721.          {
  722.             _loc6_ = mx_internal::getLayoutChildAt(_loc5_);
  723.             if(_loc6_.includeInLayout)
  724.             {
  725.                _loc6_.measuredMinWidth = 0;
  726.                _loc6_.measuredMinHeight = 0;
  727.                _loc7_ = _loc1_ ? Number(_loc6_.percentHeight) : Number(_loc6_.percentWidth);
  728.                if(!isNaN(_loc7_))
  729.                {
  730.                   _loc2_ += _loc7_;
  731.                   _loc3_++;
  732.                }
  733.             }
  734.             _loc5_++;
  735.          }
  736.          this.postLayoutChanges = [];
  737.          if(_loc2_ == 0 && _loc3_ == 0)
  738.          {
  739.             _loc5_ = _loc4_ - 1;
  740.             while(_loc5_ >= 0)
  741.             {
  742.                _loc6_ = UIComponent(getChildAt(_loc5_));
  743.                if(_loc6_.includeInLayout)
  744.                {
  745.                   _loc8_ = {"child":_loc6_};
  746.                   if(_loc1_)
  747.                   {
  748.                      if(_loc6_.explicitHeight)
  749.                      {
  750.                         _loc8_.explicitHeight = _loc6_.explicitHeight;
  751.                      }
  752.                      else
  753.                      {
  754.                         _loc8_.percentHeight = NaN;
  755.                      }
  756.                      _loc6_.percentHeight = 100;
  757.                   }
  758.                   else
  759.                   {
  760.                      if(_loc6_.explicitWidth)
  761.                      {
  762.                         _loc8_.explicitWidth = _loc6_.explicitWidth;
  763.                      }
  764.                      else if(_loc6_.percentWidth)
  765.                      {
  766.                         _loc8_.percentWidth = NaN;
  767.                      }
  768.                      _loc6_.percentWidth = 100;
  769.                   }
  770.                   this.postLayoutChanges.push(_loc8_);
  771.                   break;
  772.                }
  773.                _loc5_--;
  774.             }
  775.          }
  776.          else if(_loc2_ < 100)
  777.          {
  778.             _loc9_ = Math.ceil((100 - _loc2_) / _loc3_);
  779.             _loc5_ = 0;
  780.             while(_loc5_ < _loc4_)
  781.             {
  782.                _loc6_ = mx_internal::getLayoutChildAt(_loc5_);
  783.                if(_loc6_.includeInLayout)
  784.                {
  785.                   _loc8_ = {"child":_loc6_};
  786.                   if(_loc1_)
  787.                   {
  788.                      _loc7_ = Number(_loc6_.percentHeight);
  789.                      if(!isNaN(_loc7_))
  790.                      {
  791.                         _loc8_.percentHeight = _loc6_.percentHeight;
  792.                         this.postLayoutChanges.push(_loc8_);
  793.                         _loc6_.percentHeight = (_loc7_ + _loc9_) * unscaledHeight;
  794.                      }
  795.                   }
  796.                   else
  797.                   {
  798.                      _loc7_ = Number(_loc6_.percentWidth);
  799.                      if(!isNaN(_loc7_))
  800.                      {
  801.                         _loc8_.percentWidth = _loc6_.percentWidth;
  802.                         this.postLayoutChanges.push(_loc8_);
  803.                         _loc6_.percentWidth = (_loc7_ + _loc9_) * unscaledWidth;
  804.                      }
  805.                   }
  806.                }
  807.                _loc5_++;
  808.             }
  809.          }
  810.       }
  811.       
  812.       private function postLayoutAdjustment() : void
  813.       {
  814.          var _loc3_:Object = null;
  815.          var _loc1_:int = int(this.postLayoutChanges.length);
  816.          var _loc2_:int = 0;
  817.          while(_loc2_ < _loc1_)
  818.          {
  819.             _loc3_ = this.postLayoutChanges[_loc2_];
  820.             if(_loc3_.percentWidth !== undefined)
  821.             {
  822.                _loc3_.child.percentWidth = _loc3_.percentWidth;
  823.             }
  824.             if(_loc3_.percentHeight !== undefined)
  825.             {
  826.                _loc3_.child.percentHeight = _loc3_.percentHeight;
  827.             }
  828.             if(_loc3_.explicitWidth !== undefined)
  829.             {
  830.                _loc3_.child.explicitWidth = _loc3_.explicitWidth;
  831.             }
  832.             if(_loc3_.explicitHeight !== undefined)
  833.             {
  834.                _loc3_.child.explicitHeight = _loc3_.explicitHeight;
  835.             }
  836.             _loc2_++;
  837.          }
  838.          this.postLayoutChanges = null;
  839.       }
  840.       
  841.       private function childAddHandler(param1:ChildExistenceChangedEvent) : void
  842.       {
  843.          var _loc2_:DisplayObject = param1.relatedObject;
  844.          _loc2_.addEventListener("includeInLayoutChanged",this.child_includeInLayoutChangedHandler);
  845.          if(!IUIComponent(_loc2_).includeInLayout)
  846.          {
  847.             return;
  848.          }
  849.          ++this.numLayoutChildren;
  850.          if(this.numLayoutChildren > 1)
  851.          {
  852.             this.createDivider(this.numLayoutChildren - 2);
  853.          }
  854.          this.dbMinWidth = NaN;
  855.          this.dbMinHeight = NaN;
  856.          this.dbPreferredWidth = NaN;
  857.          this.dbPreferredHeight = NaN;
  858.       }
  859.       
  860.       private function childRemoveHandler(param1:ChildExistenceChangedEvent) : void
  861.       {
  862.          var _loc2_:DisplayObject = param1.relatedObject;
  863.          _loc2_.removeEventListener("includeInLayoutChanged",this.child_includeInLayoutChangedHandler);
  864.          if(!IUIComponent(_loc2_).includeInLayout)
  865.          {
  866.             return;
  867.          }
  868.          --this.numLayoutChildren;
  869.          if(this.numLayoutChildren > 0)
  870.          {
  871.             this.dividerLayer.removeChild(this.getDividerAt(this.numLayoutChildren - 1));
  872.          }
  873.          this.dbMinWidth = NaN;
  874.          this.dbMinHeight = NaN;
  875.          this.dbPreferredWidth = NaN;
  876.          this.dbPreferredHeight = NaN;
  877.          invalidateSize();
  878.       }
  879.       
  880.       private function child_includeInLayoutChangedHandler(param1:Event) : void
  881.       {
  882.          var _loc2_:UIComponent = UIComponent(param1.target);
  883.          if(_loc2_.includeInLayout && ++this.numLayoutChildren > 1)
  884.          {
  885.             this.createDivider(this.numLayoutChildren - 2);
  886.          }
  887.          else if(!_loc2_.includeInLayout && --this.numLayoutChildren > 0)
  888.          {
  889.             this.dividerLayer.removeChild(this.getDividerAt(this.numLayoutChildren - 1));
  890.          }
  891.          this.dbMinWidth = NaN;
  892.          this.dbMinHeight = NaN;
  893.          this.dbPreferredWidth = NaN;
  894.          this.dbPreferredHeight = NaN;
  895.          invalidateSize();
  896.       }
  897.    }
  898. }
  899.  
  900. class ChildSizeInfo
  901. {
  902.    public var deltaMin:Number;
  903.    
  904.    public var deltaMax:Number;
  905.    
  906.    public var min:Number;
  907.    
  908.    public var max:Number;
  909.    
  910.    public var size:Number;
  911.    
  912.    public function ChildSizeInfo(param1:Number, param2:Number = 0, param3:Number = 0, param4:Number = 0, param5:Number = 0)
  913.    {
  914.       super();
  915.       this.size = param1;
  916.       this.min = param2;
  917.       this.max = param3;
  918.       this.deltaMin = param4;
  919.       this.deltaMax = param5;
  920.    }
  921. }
  922.