home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Multimedija / shufflr.air / ShufflrClient.swf / scripts / mx / controls / treeClasses / HierarchicalCollectionView.as < prev    next >
Encoding:
Text File  |  2010-06-23  |  24.2 KB  |  692 lines

  1. package mx.controls.treeClasses
  2. {
  3.    import flash.events.EventDispatcher;
  4.    import flash.utils.Dictionary;
  5.    import mx.collections.ICollectionView;
  6.    import mx.collections.IViewCursor;
  7.    import mx.collections.Sort;
  8.    import mx.collections.XMLListAdapter;
  9.    import mx.collections.XMLListCollection;
  10.    import mx.collections.errors.ItemPendingError;
  11.    import mx.core.EventPriority;
  12.    import mx.core.mx_internal;
  13.    import mx.events.CollectionEvent;
  14.    import mx.events.CollectionEventKind;
  15.    import mx.events.PropertyChangeEvent;
  16.    import mx.utils.IXMLNotifiable;
  17.    import mx.utils.XMLNotifier;
  18.    
  19.    use namespace mx_internal;
  20.    
  21.    public class HierarchicalCollectionView extends EventDispatcher implements ICollectionView, IXMLNotifiable
  22.    {
  23.       mx_internal static const VERSION:String = "3.5.0.12683";
  24.       
  25.       private var itemToUID:Function;
  26.       
  27.       public var openNodes:Object;
  28.       
  29.       private var dataDescriptor:ITreeDataDescriptor;
  30.       
  31.       private var currentLength:int;
  32.       
  33.       private var parentNode:XML;
  34.       
  35.       public var parentMap:Object;
  36.       
  37.       private var cursor:HierarchicalViewCursor;
  38.       
  39.       private var childrenMap:Dictionary;
  40.       
  41.       private var treeData:ICollectionView;
  42.       
  43.       public function HierarchicalCollectionView(param1:ICollectionView, param2:ITreeDataDescriptor, param3:Function, param4:Object = null)
  44.       {
  45.          super();
  46.          parentMap = {};
  47.          childrenMap = new Dictionary(true);
  48.          treeData = param1;
  49.          treeData.addEventListener(CollectionEvent.COLLECTION_CHANGE,collectionChangeHandler,false,EventPriority.DEFAULT_HANDLER,true);
  50.          addEventListener(CollectionEvent.COLLECTION_CHANGE,expandEventHandler,false,0,true);
  51.          dataDescriptor = param2;
  52.          this.itemToUID = param3;
  53.          openNodes = param4;
  54.          currentLength = calculateLength();
  55.       }
  56.       
  57.       public function nestedCollectionChangeHandler(param1:CollectionEvent) : void
  58.       {
  59.          var _loc2_:int = 0;
  60.          var _loc3_:int = 0;
  61.          var _loc4_:int = 0;
  62.          var _loc5_:String = null;
  63.          var _loc6_:Object = null;
  64.          var _loc7_:Object = null;
  65.          var _loc8_:Array = null;
  66.          var _loc9_:CollectionEvent = null;
  67.          var _loc10_:CollectionEvent = null;
  68.          var _loc11_:int = 0;
  69.          if(param1 is CollectionEvent)
  70.          {
  71.             _loc10_ = CollectionEvent(param1);
  72.             if(_loc10_.kind == CollectionEventKind.mx_internal::EXPAND)
  73.             {
  74.                param1.stopImmediatePropagation();
  75.             }
  76.             else if(_loc10_.kind == CollectionEventKind.ADD)
  77.             {
  78.                updateLength();
  79.                _loc3_ = int(_loc10_.items.length);
  80.                _loc9_ = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE,false,true,_loc10_.kind);
  81.                _loc2_ = 0;
  82.                while(_loc2_ < _loc3_)
  83.                {
  84.                   _loc7_ = _loc10_.items[_loc2_];
  85.                   if(_loc7_ is XML)
  86.                   {
  87.                      startTrackUpdates(_loc7_);
  88.                   }
  89.                   _loc6_ = getParentItem(_loc7_);
  90.                   if(_loc6_ != null)
  91.                   {
  92.                      getVisibleNodes(_loc7_,_loc6_,_loc9_.items);
  93.                   }
  94.                   _loc2_++;
  95.                }
  96.                _loc9_.location = getVisibleLocationInSubCollection(_loc6_,_loc10_.location);
  97.                dispatchEvent(_loc9_);
  98.             }
  99.             else if(_loc10_.kind == CollectionEventKind.REMOVE)
  100.             {
  101.                _loc3_ = int(_loc10_.items.length);
  102.                _loc9_ = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE,false,true,_loc10_.kind);
  103.                _loc2_ = 0;
  104.                while(_loc2_ < _loc3_)
  105.                {
  106.                   _loc7_ = _loc10_.items[_loc2_];
  107.                   if(_loc7_ is XML)
  108.                   {
  109.                      stopTrackUpdates(_loc7_);
  110.                   }
  111.                   _loc6_ = getParentItem(_loc7_);
  112.                   if(_loc6_ != null)
  113.                   {
  114.                      getVisibleNodes(_loc7_,_loc6_,_loc9_.items);
  115.                   }
  116.                   _loc2_++;
  117.                }
  118.                _loc9_.location = getVisibleLocationInSubCollection(_loc6_,_loc10_.location);
  119.                currentLength -= _loc9_.items.length;
  120.                dispatchEvent(_loc9_);
  121.             }
  122.             else if(_loc10_.kind == CollectionEventKind.UPDATE)
  123.             {
  124.                dispatchEvent(param1);
  125.             }
  126.             else if(_loc10_.kind == CollectionEventKind.REPLACE)
  127.             {
  128.                _loc3_ = int(_loc10_.items.length);
  129.                _loc9_ = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE,false,true,CollectionEventKind.REMOVE);
  130.                _loc2_ = 0;
  131.                while(_loc2_ < _loc3_)
  132.                {
  133.                   _loc7_ = _loc10_.items[_loc2_].oldValue;
  134.                   _loc6_ = getParentItem(_loc7_);
  135.                   if(_loc6_ != null)
  136.                   {
  137.                      getVisibleNodes(_loc7_,_loc6_,_loc9_.items);
  138.                   }
  139.                   _loc2_++;
  140.                }
  141.                _loc11_ = 0;
  142.                _loc2_ = 0;
  143.                while(_loc2_ < _loc3_)
  144.                {
  145.                   _loc7_ = _loc10_.items[_loc2_].oldValue;
  146.                   if(_loc7_ is XML)
  147.                   {
  148.                      stopTrackUpdates(_loc7_);
  149.                   }
  150.                   while(_loc9_.items[_loc11_] != _loc7_)
  151.                   {
  152.                      _loc11_++;
  153.                   }
  154.                   _loc9_.items.splice(_loc11_,1);
  155.                   _loc2_++;
  156.                }
  157.                if(_loc9_.items.length)
  158.                {
  159.                   currentLength -= _loc9_.items.length;
  160.                   dispatchEvent(_loc9_);
  161.                }
  162.                dispatchEvent(param1);
  163.             }
  164.             else if(_loc10_.kind == CollectionEventKind.RESET)
  165.             {
  166.                updateLength();
  167.                _loc9_ = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE,false,true,CollectionEventKind.REFRESH);
  168.                dispatchEvent(_loc9_);
  169.             }
  170.          }
  171.       }
  172.       
  173.       private function getVisibleLocationInSubCollection(param1:Object, param2:int) : int
  174.       {
  175.          var _loc5_:ICollectionView = null;
  176.          var _loc6_:IViewCursor = null;
  177.          var _loc3_:int = param2;
  178.          var _loc4_:Object = param1;
  179.          param1 = getParentItem(param1);
  180.          while(param1 != null)
  181.          {
  182.             _loc5_ = childrenMap[param1];
  183.             _loc6_ = _loc5_.createCursor();
  184.             while(!_loc6_.afterLast)
  185.             {
  186.                if(_loc6_.current == _loc4_)
  187.                {
  188.                   _loc3_++;
  189.                   break;
  190.                }
  191.                _loc3_ += calculateLength(_loc6_.current,param1) + 1;
  192.                _loc6_.moveNext();
  193.             }
  194.             _loc4_ = param1;
  195.             param1 = getParentItem(param1);
  196.          }
  197.          _loc6_ = treeData.createCursor();
  198.          while(!_loc6_.afterLast)
  199.          {
  200.             if(_loc6_.current == _loc4_)
  201.             {
  202.                _loc3_++;
  203.                break;
  204.             }
  205.             _loc3_ += calculateLength(_loc6_.current,param1) + 1;
  206.             _loc6_.moveNext();
  207.          }
  208.          return _loc3_;
  209.       }
  210.       
  211.       public function expandEventHandler(param1:CollectionEvent) : void
  212.       {
  213.          var _loc2_:CollectionEvent = null;
  214.          if(param1 is CollectionEvent)
  215.          {
  216.             _loc2_ = CollectionEvent(param1);
  217.             if(_loc2_.kind == CollectionEventKind.mx_internal::EXPAND)
  218.             {
  219.                param1.stopImmediatePropagation();
  220.                updateLength();
  221.             }
  222.          }
  223.       }
  224.       
  225.       private function updateLength(param1:Object = null, param2:Object = null) : void
  226.       {
  227.          currentLength = calculateLength();
  228.       }
  229.       
  230.       private function startTrackUpdates(param1:Object) : void
  231.       {
  232.          XMLNotifier.getInstance().watchXML(param1,this);
  233.       }
  234.       
  235.       private function getVisibleLocation(param1:int) : int
  236.       {
  237.          var _loc2_:int = 0;
  238.          var _loc3_:IViewCursor = treeData.createCursor();
  239.          var _loc4_:int = 0;
  240.          while(_loc4_ < param1 && !_loc3_.afterLast)
  241.          {
  242.             _loc2_ += calculateLength(_loc3_.current,null) + 1;
  243.             _loc3_.moveNext();
  244.             _loc4_++;
  245.          }
  246.          return _loc2_;
  247.       }
  248.       
  249.       public function describeData() : Object
  250.       {
  251.          return null;
  252.       }
  253.       
  254.       public function get sort() : Sort
  255.       {
  256.          return null;
  257.       }
  258.       
  259.       public function contains(param1:Object) : Boolean
  260.       {
  261.          var _loc2_:IViewCursor = createCursor();
  262.          var _loc3_:Boolean = false;
  263.          while(!_loc3_)
  264.          {
  265.             if(_loc2_.current == param1)
  266.             {
  267.                return true;
  268.             }
  269.             _loc3_ = _loc2_.moveNext();
  270.          }
  271.          return false;
  272.       }
  273.       
  274.       private function stopTrackUpdates(param1:Object) : void
  275.       {
  276.          XMLNotifier.getInstance().unwatchXML(param1,this);
  277.       }
  278.       
  279.       public function xmlNotification(param1:Object, param2:String, param3:Object, param4:Object, param5:Object) : void
  280.       {
  281.          var _loc6_:String = null;
  282.          var _loc7_:Object = null;
  283.          var _loc8_:Object = null;
  284.          var _loc9_:XMLListCollection = null;
  285.          var _loc10_:int = 0;
  286.          var _loc11_:CollectionEvent = null;
  287.          var _loc12_:XMLListAdapter = null;
  288.          var _loc13_:* = undefined;
  289.          var _loc14_:* = undefined;
  290.          var _loc15_:XMLList = null;
  291.          var _loc16_:XMLListCollection = null;
  292.          var _loc17_:int = 0;
  293.          var _loc18_:int = 0;
  294.          if(param1 === param3)
  295.          {
  296.             switch(param2)
  297.             {
  298.                case "nodeAdded":
  299.                   for(_loc13_ in childrenMap)
  300.                   {
  301.                      if(_loc13_ === param1)
  302.                      {
  303.                         _loc12_ = childrenMap[_loc13_].list as XMLListAdapter;
  304.                         break;
  305.                      }
  306.                   }
  307.                   if(!_loc12_ && param3 is XML && XML(param3).children().length() == 1)
  308.                   {
  309.                      _loc12_ = (getChildren(param3) as XMLListCollection).list as XMLListAdapter;
  310.                   }
  311.                   if(Boolean(_loc12_) && !_loc12_.busy())
  312.                   {
  313.                      if(childrenMap[_loc13_] === treeData)
  314.                      {
  315.                         _loc9_ = treeData as XMLListCollection;
  316.                         if(parentNode)
  317.                         {
  318.                            _loc9_.mx_internal::dispatchResetEvent = false;
  319.                            _loc9_.source = parentNode.*;
  320.                         }
  321.                      }
  322.                      else
  323.                      {
  324.                         _loc9_ = getChildren(_loc13_) as XMLListCollection;
  325.                      }
  326.                      if(_loc9_)
  327.                      {
  328.                         _loc10_ = int(param4.childIndex());
  329.                         _loc11_ = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
  330.                         _loc11_.kind = CollectionEventKind.ADD;
  331.                         _loc11_.location = _loc10_;
  332.                         _loc11_.items = [param4];
  333.                         _loc9_.dispatchEvent(_loc11_);
  334.                      }
  335.                   }
  336.                   break;
  337.                case "nodeRemoved":
  338.                   for(_loc14_ in childrenMap)
  339.                   {
  340.                      if(_loc14_ === param1)
  341.                      {
  342.                         _loc9_ = childrenMap[_loc14_];
  343.                         _loc12_ = _loc9_.list as XMLListAdapter;
  344.                         if((Boolean(_loc12_)) && !_loc12_.busy())
  345.                         {
  346.                            _loc15_ = _loc9_.source as XMLList;
  347.                            if(childrenMap[_loc14_] === treeData)
  348.                            {
  349.                               _loc9_ = treeData as XMLListCollection;
  350.                               if(parentNode)
  351.                               {
  352.                                  _loc9_.mx_internal::dispatchResetEvent = false;
  353.                                  _loc9_.source = parentNode.*;
  354.                               }
  355.                            }
  356.                            else
  357.                            {
  358.                               _loc16_ = _loc9_;
  359.                               _loc9_ = getChildren(_loc14_) as XMLListCollection;
  360.                               if(!_loc9_)
  361.                               {
  362.                                  _loc16_.addEventListener(CollectionEvent.COLLECTION_CHANGE,nestedCollectionChangeHandler,false,0,true);
  363.                                  _loc11_ = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
  364.                                  _loc11_.kind = CollectionEventKind.REMOVE;
  365.                                  _loc11_.location = 0;
  366.                                  _loc11_.items = [param4];
  367.                                  _loc16_.dispatchEvent(_loc11_);
  368.                                  _loc16_.removeEventListener(CollectionEvent.COLLECTION_CHANGE,nestedCollectionChangeHandler);
  369.                               }
  370.                            }
  371.                            if(_loc9_)
  372.                            {
  373.                               _loc17_ = int(_loc15_.length());
  374.                               _loc18_ = 0;
  375.                               while(_loc18_ < _loc17_)
  376.                               {
  377.                                  if(_loc15_[_loc18_] === param4)
  378.                                  {
  379.                                     _loc11_ = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
  380.                                     _loc11_.kind = CollectionEventKind.REMOVE;
  381.                                     _loc11_.location = _loc10_;
  382.                                     _loc11_.items = [param4];
  383.                                     _loc9_.dispatchEvent(_loc11_);
  384.                                     break;
  385.                                  }
  386.                                  _loc18_++;
  387.                               }
  388.                            }
  389.                         }
  390.                         break;
  391.                      }
  392.                   }
  393.             }
  394.          }
  395.       }
  396.       
  397.       public function itemUpdated(param1:Object, param2:Object = null, param3:Object = null, param4:Object = null) : void
  398.       {
  399.          var _loc5_:CollectionEvent = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
  400.          _loc5_.kind = CollectionEventKind.UPDATE;
  401.          var _loc6_:PropertyChangeEvent = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE);
  402.          _loc6_.property = param2;
  403.          _loc6_.oldValue = param3;
  404.          _loc6_.newValue = param4;
  405.          _loc5_.items.push(_loc6_);
  406.          dispatchEvent(_loc5_);
  407.       }
  408.       
  409.       public function enableAutoUpdate() : void
  410.       {
  411.       }
  412.       
  413.       public function set sort(param1:Sort) : void
  414.       {
  415.       }
  416.       
  417.       public function getParentItem(param1:Object) : *
  418.       {
  419.          var _loc2_:String = itemToUID(param1);
  420.          if(parentMap.hasOwnProperty(_loc2_))
  421.          {
  422.             return parentMap[_loc2_];
  423.          }
  424.          return undefined;
  425.       }
  426.       
  427.       private function getVisibleNodes(param1:Object, param2:Object, param3:Array) : void
  428.       {
  429.          var _loc4_:ICollectionView = null;
  430.          var _loc6_:int = 0;
  431.          var _loc7_:int = 0;
  432.          param3.push(param1);
  433.          var _loc5_:String = itemToUID(param1);
  434.          parentMap[_loc5_] = param2;
  435.          if(openNodes[_loc5_] && dataDescriptor.isBranch(param1,treeData) && dataDescriptor.hasChildren(param1,treeData))
  436.          {
  437.             _loc4_ = getChildren(param1);
  438.             if(_loc4_ != null)
  439.             {
  440.                _loc6_ = _loc4_.length;
  441.                _loc7_ = 0;
  442.                while(_loc7_ < _loc6_)
  443.                {
  444.                   getVisibleNodes(_loc4_[_loc7_],param1,param3);
  445.                   _loc7_++;
  446.                }
  447.             }
  448.          }
  449.       }
  450.       
  451.       public function refresh() : Boolean
  452.       {
  453.          var _loc1_:CollectionEvent = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
  454.          _loc1_.kind = CollectionEventKind.REFRESH;
  455.          dispatchEvent(_loc1_);
  456.          return true;
  457.       }
  458.       
  459.       public function get length() : int
  460.       {
  461.          return currentLength;
  462.       }
  463.       
  464.       public function set filterFunction(param1:Function) : void
  465.       {
  466.       }
  467.       
  468.       public function calculateLength(param1:Object = null, param2:Object = null) : int
  469.       {
  470.          var length:int = 0;
  471.          var childNodes:ICollectionView = null;
  472.          var modelOffset:int = 0;
  473.          var modelCursor:IViewCursor = null;
  474.          var parNode:* = undefined;
  475.          var uid:String = null;
  476.          var numChildren:int = 0;
  477.          var i:int = 0;
  478.          var node:Object = param1;
  479.          var parent:Object = param2;
  480.          length = 0;
  481.          var firstNode:Boolean = true;
  482.          if(node == null)
  483.          {
  484.             modelOffset = 0;
  485.             modelCursor = treeData.createCursor();
  486.             if(modelCursor.beforeFirst)
  487.             {
  488.                return treeData.length;
  489.             }
  490.             while(!modelCursor.afterLast)
  491.             {
  492.                node = modelCursor.current;
  493.                if(node is XML)
  494.                {
  495.                   if(firstNode)
  496.                   {
  497.                      firstNode = false;
  498.                      parNode = node.parent();
  499.                      if(parNode)
  500.                      {
  501.                         startTrackUpdates(parNode);
  502.                         childrenMap[parNode] = treeData;
  503.                         parentNode = parNode;
  504.                      }
  505.                   }
  506.                   startTrackUpdates(node);
  507.                }
  508.                if(node === null)
  509.                {
  510.                   length += 1;
  511.                }
  512.                else
  513.                {
  514.                   length += calculateLength(node,null) + 1;
  515.                }
  516.                modelOffset++;
  517.                try
  518.                {
  519.                   modelCursor.moveNext();
  520.                }
  521.                catch(e:ItemPendingError)
  522.                {
  523.                   length += treeData.length - modelOffset;
  524.                   return length;
  525.                }
  526.             }
  527.          }
  528.          else
  529.          {
  530.             uid = itemToUID(node);
  531.             parentMap[uid] = parent;
  532.             if(node != null && openNodes[uid] && dataDescriptor.isBranch(node,treeData) && dataDescriptor.hasChildren(node,treeData))
  533.             {
  534.                childNodes = getChildren(node);
  535.                if(childNodes != null)
  536.                {
  537.                   numChildren = childNodes.length;
  538.                   i = 0;
  539.                   while(i < numChildren)
  540.                   {
  541.                      if(node is XML)
  542.                      {
  543.                         startTrackUpdates(childNodes[i]);
  544.                      }
  545.                      length += calculateLength(childNodes[i],node) + 1;
  546.                      i++;
  547.                   }
  548.                }
  549.             }
  550.          }
  551.          return length;
  552.       }
  553.       
  554.       public function disableAutoUpdate() : void
  555.       {
  556.       }
  557.       
  558.       public function createCursor() : IViewCursor
  559.       {
  560.          return new HierarchicalViewCursor(this,treeData,dataDescriptor,itemToUID,openNodes);
  561.       }
  562.       
  563.       private function getChildren(param1:Object) : ICollectionView
  564.       {
  565.          var _loc2_:ICollectionView = dataDescriptor.getChildren(param1,treeData);
  566.          var _loc3_:ICollectionView = childrenMap[param1];
  567.          if(_loc3_ != _loc2_)
  568.          {
  569.             if(_loc3_ != null)
  570.             {
  571.                _loc3_.removeEventListener(CollectionEvent.COLLECTION_CHANGE,nestedCollectionChangeHandler);
  572.             }
  573.             if(_loc2_)
  574.             {
  575.                _loc2_.addEventListener(CollectionEvent.COLLECTION_CHANGE,nestedCollectionChangeHandler,false,0,true);
  576.                childrenMap[param1] = _loc2_;
  577.             }
  578.             else
  579.             {
  580.                delete childrenMap[param1];
  581.             }
  582.          }
  583.          return _loc2_;
  584.       }
  585.       
  586.       public function get filterFunction() : Function
  587.       {
  588.          return null;
  589.       }
  590.       
  591.       public function collectionChangeHandler(param1:CollectionEvent) : void
  592.       {
  593.          var _loc2_:int = 0;
  594.          var _loc3_:int = 0;
  595.          var _loc4_:int = 0;
  596.          var _loc5_:String = null;
  597.          var _loc6_:Object = null;
  598.          var _loc7_:Object = null;
  599.          var _loc8_:Array = null;
  600.          var _loc9_:CollectionEvent = null;
  601.          var _loc10_:CollectionEvent = null;
  602.          var _loc11_:int = 0;
  603.          if(param1 is CollectionEvent)
  604.          {
  605.             _loc10_ = CollectionEvent(param1);
  606.             if(_loc10_.kind == CollectionEventKind.RESET)
  607.             {
  608.                updateLength();
  609.                dispatchEvent(param1);
  610.             }
  611.             else if(_loc10_.kind == CollectionEventKind.ADD)
  612.             {
  613.                _loc3_ = int(_loc10_.items.length);
  614.                _loc9_ = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE,false,true,_loc10_.kind);
  615.                _loc9_.location = getVisibleLocation(_loc10_.location);
  616.                _loc2_ = 0;
  617.                while(_loc2_ < _loc3_)
  618.                {
  619.                   _loc7_ = _loc10_.items[_loc2_];
  620.                   if(_loc7_ is XML)
  621.                   {
  622.                      startTrackUpdates(_loc7_);
  623.                   }
  624.                   getVisibleNodes(_loc7_,null,_loc9_.items);
  625.                   _loc2_++;
  626.                }
  627.                currentLength += _loc9_.items.length;
  628.                dispatchEvent(_loc9_);
  629.             }
  630.             else if(_loc10_.kind == CollectionEventKind.REMOVE)
  631.             {
  632.                _loc3_ = int(_loc10_.items.length);
  633.                _loc9_ = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE,false,true,_loc10_.kind);
  634.                _loc9_.location = getVisibleLocation(_loc10_.location);
  635.                _loc2_ = 0;
  636.                while(_loc2_ < _loc3_)
  637.                {
  638.                   _loc7_ = _loc10_.items[_loc2_];
  639.                   if(_loc7_ is XML)
  640.                   {
  641.                      stopTrackUpdates(_loc7_);
  642.                   }
  643.                   getVisibleNodes(_loc7_,null,_loc9_.items);
  644.                   _loc2_++;
  645.                }
  646.                currentLength -= _loc9_.items.length;
  647.                dispatchEvent(_loc9_);
  648.             }
  649.             else if(_loc10_.kind == CollectionEventKind.UPDATE)
  650.             {
  651.                dispatchEvent(param1);
  652.             }
  653.             else if(_loc10_.kind == CollectionEventKind.REPLACE)
  654.             {
  655.                _loc3_ = int(_loc10_.items.length);
  656.                _loc9_ = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE,false,true,CollectionEventKind.REMOVE);
  657.                _loc2_ = 0;
  658.                while(_loc2_ < _loc3_)
  659.                {
  660.                   _loc7_ = _loc10_.items[_loc2_].oldValue;
  661.                   if(_loc7_ is XML)
  662.                   {
  663.                      stopTrackUpdates(_loc7_);
  664.                   }
  665.                   getVisibleNodes(_loc7_,null,_loc9_.items);
  666.                   _loc2_++;
  667.                }
  668.                _loc11_ = 0;
  669.                _loc2_ = 0;
  670.                while(_loc2_ < _loc3_)
  671.                {
  672.                   _loc7_ = _loc10_.items[_loc2_].oldValue;
  673.                   while(_loc9_.items[_loc11_] != _loc7_)
  674.                   {
  675.                      _loc11_++;
  676.                   }
  677.                   _loc9_.items.splice(_loc11_,1);
  678.                   _loc2_++;
  679.                }
  680.                if(_loc9_.items.length)
  681.                {
  682.                   currentLength -= _loc9_.items.length;
  683.                   dispatchEvent(_loc9_);
  684.                }
  685.                dispatchEvent(param1);
  686.             }
  687.          }
  688.       }
  689.    }
  690. }
  691.  
  692.