home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / sky-chopper.swf / scripts / __Packages / mx / controls / Menu.as < prev    next >
Encoding:
Text File  |  2005-09-29  |  28.5 KB  |  983 lines

  1. class mx.controls.Menu extends mx.controls.listclasses.ScrollSelectList
  2. {
  3.    var __activator;
  4.    var mask_mc;
  5.    var listContent;
  6.    var border_mc;
  7.    var __menuCache;
  8.    var __width;
  9.    var __height;
  10.    var invRowHeight;
  11.    var invUpdateSize;
  12.    var __menuDataProvider;
  13.    var groupName;
  14.    var __menuBar;
  15.    var popupMask;
  16.    var wasJustCreated;
  17.    var popupTween;
  18.    var isPressed;
  19.    var __activeChildren;
  20.    var __lastRowRolledOver;
  21.    var clearSelected;
  22.    var anchorRow;
  23.    var supposedToLoseFocus;
  24.    var __dataProvider;
  25.    var getLength;
  26.    var rows;
  27.    var __namedItems;
  28.    var __radioGroups;
  29.    var _selection;
  30.    var _members;
  31.    var __anchor;
  32.    var __parentMenu;
  33.    var __anchorIndex;
  34.    var dragScrolling;
  35.    var __timer;
  36.    var __timeOut;
  37.    var focusManager;
  38.    var getSelectedIndex;
  39.    var wasKeySelected;
  40.    var selectedIndex;
  41.    var selectedItem;
  42.    static var symbolName = "Menu";
  43.    static var symbolOwner = mx.controls.Menu;
  44.    var className = "Menu";
  45.    static var version = "2.0.0.360";
  46.    static var mixit = mx.controls.treeclasses.TreeDataProvider.Initialize(XMLNode);
  47.    static var mixit2 = mx.controls.menuclasses.MenuDataProvider.Initialize(XMLNode);
  48.    var __hScrollPolicy = "off";
  49.    var __vScrollPolicy = "off";
  50.    var __rowRenderer = "MenuRow";
  51.    var __rowHeight = 19;
  52.    var __wasVisible = false;
  53.    var __enabled = true;
  54.    var __openDelay = 250;
  55.    var __closeDelay = 250;
  56.    var __delayQueue = new Array();
  57.    var __iconField = "icon";
  58.    function Menu()
  59.    {
  60.       super();
  61.    }
  62.    static function createMenu(parent, mdp, initObj)
  63.    {
  64.       if(parent == undefined)
  65.       {
  66.          parent = _root;
  67.       }
  68.       if(mdp == undefined)
  69.       {
  70.          mdp = new XML();
  71.       }
  72.       var _loc3_ = mx.managers.PopUpManager.createPopUp(parent,mx.controls.Menu,false,initObj,true);
  73.       if(_loc3_ == undefined)
  74.       {
  75.          trace("Failed to create a new menu, probably because there is no Menu in the Library");
  76.       }
  77.       else
  78.       {
  79.          _loc3_.isPressed = true;
  80.          _loc3_.mouseDownOutsideHandler = function(event)
  81.          {
  82.             if(!this.isMouseOverMenu() && !this.__activator.hitTest(_root._xmouse,_root._ymouse))
  83.             {
  84.                this.hideAllMenus();
  85.             }
  86.          };
  87.          _loc3_.dataProvider = mdp;
  88.       }
  89.       return _loc3_;
  90.    }
  91.    static function isItemEnabled(itm)
  92.    {
  93.       var _loc1_ = itm.attributes.enabled;
  94.       return (_loc1_ == undefined || _loc1_ == true || _loc1_.toLowerCase() == "true") && itm.attributes.type.toLowerCase() != "separator";
  95.    }
  96.    static function isItemSelected(itm)
  97.    {
  98.       var _loc1_ = itm.attributes.selected;
  99.       return _loc1_ == true || _loc1_.toLowerCase() == "true";
  100.    }
  101.    function init(Void)
  102.    {
  103.       super.init();
  104.       this.visible = false;
  105.    }
  106.    function createChildren(Void)
  107.    {
  108.       super.createChildren();
  109.       this.listContent.setMask(this.mask_mc);
  110.       this.mask_mc.removeMovieClip();
  111.       this.border_mc.move(0,0);
  112.       this.border_mc.borderStyle = "menuBorder";
  113.    }
  114.    function propagateToSubMenus(prop, value)
  115.    {
  116.       for(var _loc5_ in this.__menuCache)
  117.       {
  118.          var _loc2_ = this.__menuCache[_loc5_];
  119.          if(_loc2_ != this)
  120.          {
  121.             _loc2_["set" + prop](value);
  122.          }
  123.       }
  124.    }
  125.    function setLabelField(lbl)
  126.    {
  127.       super.setLabelField(lbl);
  128.       this.propagateToSubMenus("LabelField",lbl);
  129.    }
  130.    function setLabelFunction(lbl)
  131.    {
  132.       super.setLabelFunction(lbl);
  133.       this.propagateToSubMenus("LabelFunction",lbl);
  134.    }
  135.    function setCellRenderer(cR)
  136.    {
  137.       super.setCellRenderer(cR);
  138.       this.propagateToSubMenus("CellRenderer",cR);
  139.    }
  140.    function setRowHeight(v)
  141.    {
  142.       super.setRowHeight(v);
  143.       this.propagateToSubMenus("RowHeight",v);
  144.    }
  145.    function setIconField(v)
  146.    {
  147.       super.setIconField(v);
  148.       this.propagateToSubMenus("IconField",v);
  149.    }
  150.    function setIconFunction(v)
  151.    {
  152.       super.setIconFunction(v);
  153.       this.propagateToSubMenus("IconFunction",v);
  154.    }
  155.    function size(Void)
  156.    {
  157.       super.size();
  158.       var _loc3_ = this.getViewMetrics();
  159.       this.layoutContent(_loc3_.left,_loc3_.top,this.__width - _loc3_.left - _loc3_.right,this.__height - _loc3_.top - _loc3_.bottom);
  160.    }
  161.    function draw(Void)
  162.    {
  163.       if(this.invRowHeight)
  164.       {
  165.          super.draw();
  166.          this.listContent.setMask(this.mask_mc);
  167.          this.invUpdateSize = true;
  168.       }
  169.       super.draw();
  170.       if(this.invUpdateSize)
  171.       {
  172.          this.updateSize();
  173.       }
  174.    }
  175.    function onSetFocus()
  176.    {
  177.       super.onSetFocus();
  178.       this.getFocusManager().defaultPushButtonEnabled = false;
  179.    }
  180.    function setDataProvider(dP)
  181.    {
  182.       if(typeof dP == "string")
  183.       {
  184.          dP = new XML(dP).firstChild;
  185.       }
  186.       this.__menuDataProvider.removeEventListener("modelChanged",this);
  187.       this.__menuDataProvider = dP;
  188.       if(!(this.__menuDataProvider instanceof XML))
  189.       {
  190.          this.__menuDataProvider.isTreeRoot = true;
  191.       }
  192.       this.__menuDataProvider.addEventListener("modelChanged",this);
  193.       this.modelChanged({eventName:"updateTree"});
  194.    }
  195.    function getDataProvider()
  196.    {
  197.       return this.__menuDataProvider;
  198.    }
  199.    function addMenuItem(arg)
  200.    {
  201.       return this.__menuDataProvider.addMenuItem(arg);
  202.    }
  203.    function addMenuItemAt(index, arg)
  204.    {
  205.       return this.__menuDataProvider.addMenuItemAt(index,arg);
  206.    }
  207.    function removeMenuItemAt(index)
  208.    {
  209.       var _loc2_ = this.getMenuItemAt(index);
  210.       if(_loc2_ != undefined && _loc2_ != null)
  211.       {
  212.          _loc2_.removeMenuItem();
  213.       }
  214.       return _loc2_;
  215.    }
  216.    function removeMenuItem(item)
  217.    {
  218.       return this.removeMenuItemAt(this.indexOf(item));
  219.    }
  220.    function removeAll(Void)
  221.    {
  222.       return this.__menuDataProvider.removeAll();
  223.    }
  224.    function getMenuItemAt(index)
  225.    {
  226.       return this.__menuDataProvider.getMenuItemAt(index);
  227.    }
  228.    function setMenuItemSelected(item, select)
  229.    {
  230.       if(item.attributes.type == "radio")
  231.       {
  232.          var _loc3_ = this.getRootMenu();
  233.          this.groupName = item.attributes.groupName;
  234.          _loc3_[this.groupName].setGroupSelection(item);
  235.          return undefined;
  236.       }
  237.       if(select != item.attributes.selected)
  238.       {
  239.          item.attributes.selected = select;
  240.          item.updateViews({eventName:"selectionChanged",node:item});
  241.       }
  242.    }
  243.    function setMenuItemEnabled(item, enable)
  244.    {
  245.       if(enable != item.attributes.enabled)
  246.       {
  247.          item.attributes.enabled = enable;
  248.          item.updateViews({eventName:"enabledChanged",node:item});
  249.       }
  250.    }
  251.    function indexOf(item)
  252.    {
  253.       return this.__menuDataProvider.indexOf(item);
  254.    }
  255.    function show(x, y)
  256.    {
  257.       if(!this.visible)
  258.       {
  259.          var _loc2_ = this.getRootMenu();
  260.          _loc2_.dispatchEvent({type:"menuShow",menuBar:this.__menuBar,menu:this,menuItem:this.__menuDataProvider});
  261.          if(x != undefined)
  262.          {
  263.             this._x = x;
  264.             if(y != undefined)
  265.             {
  266.                this._y = y;
  267.             }
  268.          }
  269.          if(this != _loc2_)
  270.          {
  271.             var _loc5_ = this._x + this._width - Stage.width;
  272.             if(_loc5_ > 0)
  273.             {
  274.                this._x -= _loc5_;
  275.                if(this._x < 0)
  276.                {
  277.                   this._x = 0;
  278.                }
  279.             }
  280.          }
  281.          this.popupMask = this.attachMovie("BoundingBox","pMask_mc",6000);
  282.          this.setMask(this.popupMask);
  283.          var _loc3_ = this.width;
  284.          if(_loc3_ < 50)
  285.          {
  286.             _loc3_ = 100;
  287.          }
  288.          this.popupMask._width = _loc3_;
  289.          this.popupMask._height = this.height;
  290.          this.popupMask._x = - this.popupMask._width;
  291.          this.popupMask._y = - this.popupMask._height;
  292.          var _loc4_ = this.getStyle("popupDuration");
  293.          if(this.wasJustCreated && _loc4_ < 200)
  294.          {
  295.             _loc4_ = 200;
  296.             delete this.wasJustCreated;
  297.          }
  298.          this.popupTween = new mx.effects.Tween(this,[this.popupMask._x,this.popupMask._y],[0,0],_loc4_);
  299.          this.visible = true;
  300.          this.isPressed = true;
  301.          if(!this.__menuBar && _loc2_ == this)
  302.          {
  303.             Selection.setFocus(this);
  304.          }
  305.       }
  306.    }
  307.    function onTweenUpdate(val)
  308.    {
  309.       this.popupMask._width = this.width;
  310.       this.popupMask._x = val[0];
  311.       this.popupMask._y = val[1];
  312.    }
  313.    function onTweenEnd(val)
  314.    {
  315.       this.popupMask._x = val[0];
  316.       this.popupMask._y = val[1];
  317.       this.setMask(undefined);
  318.       this.popupMask.removeMovieClip();
  319.    }
  320.    function hide(Void)
  321.    {
  322.       if(this.visible)
  323.       {
  324.          for(var _loc2_ in this.__activeChildren)
  325.          {
  326.             this.__activeChildren[_loc2_].hide();
  327.          }
  328.          this.__lastRowRolledOver = undefined;
  329.          this.clearSelected();
  330.          if(this.anchorRow != undefined)
  331.          {
  332.             this.anchorRow.highlight._visible = false;
  333.          }
  334.          this.visible = false;
  335.          this.isPressed = false;
  336.          this.__wasVisible = false;
  337.          var _loc3_ = this.getRootMenu();
  338.          _loc3_.dispatchEvent({type:"menuHide",menuBar:this.__menuBar,menu:this,menuItem:this.__menuDataProvider});
  339.       }
  340.    }
  341.    function onKillFocus()
  342.    {
  343.       super.onKillFocus();
  344.       this.getFocusManager().defaultPushButtonEnabled = true;
  345.       if(this.supposedToLoseFocus == undefined)
  346.       {
  347.          this.hideAllMenus();
  348.       }
  349.       delete this.supposedToLoseFocus;
  350.    }
  351.    function modelChanged(eventObj)
  352.    {
  353.       var _loc3_ = eventObj.eventName;
  354.       if(_loc3_ == "updateTree")
  355.       {
  356.          this.__dataProvider.removeAll();
  357.          this.__dataProvider.addItemsAt(0,this.__menuDataProvider.childNodes);
  358.          this.invUpdateSize = true;
  359.          this.invalidate();
  360.          super.modelChanged({eventName:"updateAll"});
  361.          this.deinstallAllItems();
  362.          this.installItem(this.__menuDataProvider);
  363.          if(this.__menuCache == undefined)
  364.          {
  365.             this.__menuCache = new Object();
  366.          }
  367.          this.__menuCache[this.__menuDataProvider.getID()] = this;
  368.       }
  369.       else if(_loc3_ == "addNode" || _loc3_ == "removeNode")
  370.       {
  371.          var _loc5_ = eventObj.node;
  372.          var _loc6_ = eventObj.parentNode;
  373.          var _loc7_ = this.__menuCache[_loc6_.getID()];
  374.          if(_loc3_ == "removeNode")
  375.          {
  376.             this.deleteDependentSubMenus(_loc5_);
  377.             _loc7_.removeItemAt(eventObj.index);
  378.             this.deinstallItem(_loc5_);
  379.          }
  380.          else
  381.          {
  382.             _loc7_.addItemAt(eventObj.index,_loc5_);
  383.             this.installItem(_loc5_);
  384.          }
  385.          _loc7_.invUpdateSize = true;
  386.          _loc7_.invalidate();
  387.          var _loc8_ = this.__menuCache[_loc6_.parentNode.getID()];
  388.          _loc8_.invUpdateControl = true;
  389.          _loc8_.invalidate();
  390.       }
  391.       else if(_loc3_ == "selectionChanged" || _loc3_ == "enabledChanged")
  392.       {
  393.          _loc7_ = this.__menuCache[eventObj.node.parentNode.getID()];
  394.          _loc7_.invUpdateControl = true;
  395.          _loc7_.invalidate();
  396.       }
  397.       else
  398.       {
  399.          super.modelChanged(eventObj);
  400.       }
  401.    }
  402.    function updateSize()
  403.    {
  404.       delete this.invUpdateSize;
  405.       var _loc2_ = this.calcHeight();
  406.       if(this.getLength() != this.__rowCount)
  407.       {
  408.          this.setSize(0,_loc2_);
  409.       }
  410.       this.setSize(this.calcWidth(),_loc2_);
  411.    }
  412.    function calcWidth()
  413.    {
  414.       var _loc4_ = -1;
  415.       var _loc3_ = undefined;
  416.       var _loc2_ = 0;
  417.       while(_loc2_ < this.rows.length)
  418.       {
  419.          _loc3_ = this.rows[_loc2_].getIdealWidth();
  420.          if(_loc3_ > _loc4_)
  421.          {
  422.             _loc4_ = _loc3_;
  423.          }
  424.          _loc2_ = _loc2_ + 1;
  425.       }
  426.       var _loc5_ = this.getStyle("textIndent");
  427.       if(_loc5_ == undefined)
  428.       {
  429.          _loc5_ = 0;
  430.       }
  431.       return _loc4_ + _loc5_;
  432.    }
  433.    function calcHeight()
  434.    {
  435.       var _loc2_ = this.getViewMetrics();
  436.       return this.__dataProvider.length * this.__rowHeight + _loc2_.top + _loc2_.bottom;
  437.    }
  438.    function invalidateStyle(propName)
  439.    {
  440.       super.invalidateStyle(propName);
  441.       for(var _loc4_ in this.__activeChildren)
  442.       {
  443.          this.__activeChildren[_loc4_].invalidateStyle(propName);
  444.       }
  445.    }
  446.    function notifyStyleChangeInChildren(sheetName, styleProp, newValue)
  447.    {
  448.       super.notifyStyleChangeInChildren(sheetName,styleProp,newValue);
  449.       for(var _loc6_ in this.__activeChildren)
  450.       {
  451.          this.__activeChildren[_loc6_].notifyStyleChangeInChildren(sheetName,styleProp,newValue);
  452.       }
  453.    }
  454.    function deleteDependentSubMenus(menuItem)
  455.    {
  456.       var _loc2_ = menuItem.childNodes;
  457.       for(var _loc3_ in _loc2_)
  458.       {
  459.          this.deleteDependentSubMenus(_loc2_[_loc3_]);
  460.       }
  461.       var _loc4_ = this.__menuCache[menuItem.getID()];
  462.       if(_loc4_ != undefined)
  463.       {
  464.          _loc4_.hide();
  465.          delete this.__menuCache[menuItem.getID()];
  466.       }
  467.    }
  468.    function installItem(item)
  469.    {
  470.       if(item.attributes.instanceName != undefined)
  471.       {
  472.          var _loc6_ = item.attributes.instanceName;
  473.          if(this[_loc6_] != undefined)
  474.          {
  475.             trace("WARNING:  Duplicate menu item instanceNames - " + _loc6_);
  476.          }
  477.          if(this.__namedItems == undefined)
  478.          {
  479.             this.__namedItems = new Object();
  480.          }
  481.          this.__namedItems[_loc6_] = item;
  482.          this[_loc6_] = item;
  483.       }
  484.       if(item.attributes.type == "radio" && item.attributes.groupName != undefined)
  485.       {
  486.          var _loc5_ = item.attributes.groupName;
  487.          var _loc2_ = this[_loc5_];
  488.          if(_loc2_ == undefined)
  489.          {
  490.             _loc2_ = new Object();
  491.             _loc2_.name = _loc5_;
  492.             _loc2_._rootMenu = this;
  493.             _loc2_._members = new Object();
  494.             _loc2_._memberCount = 0;
  495.             _loc2_.getGroupSelection = this.getGroupSelection;
  496.             _loc2_.setGroupSelection = this.setGroupSelection;
  497.             _loc2_.addProperty("selection",_loc2_.getGroupSelection,_loc2_.setGroupSelection);
  498.             if(this.__radioGroups == undefined)
  499.             {
  500.                this.__radioGroups = new Object();
  501.             }
  502.             this.__radioGroups[_loc5_] = _loc2_;
  503.             this[_loc5_] = _loc2_;
  504.          }
  505.          _loc2_._members[item.getID()] = item;
  506.          _loc2_._memberCount = _loc2_._memberCount + 1;
  507.          if(mx.controls.Menu.isItemSelected(item))
  508.          {
  509.             _loc2_.selection = item;
  510.          }
  511.       }
  512.       var _loc3_ = item.childNodes;
  513.       for(var _loc7_ in _loc3_)
  514.       {
  515.          this.installItem(_loc3_[_loc7_]);
  516.       }
  517.    }
  518.    function deinstallItem(item)
  519.    {
  520.       var _loc2_ = item.childNodes;
  521.       for(var _loc5_ in _loc2_)
  522.       {
  523.          this.deinstallItem(_loc2_[_loc5_]);
  524.       }
  525.       if(item.attributes.instanceName != undefined)
  526.       {
  527.          var _loc7_ = item.attributes.instanceName;
  528.          delete this[_loc7_];
  529.          delete this.__namedItems[_loc7_];
  530.       }
  531.       if(item.attributes.type == "radio" && item.attributes.groupName != undefined)
  532.       {
  533.          var _loc6_ = item.attributes.groupName;
  534.          var _loc3_ = this[_loc6_];
  535.          if(_loc3_ == undefined)
  536.          {
  537.             return undefined;
  538.          }
  539.          delete _loc3_._members[item.getID()];
  540.          _loc3_._memberCount = _loc3_._memberCount - 1;
  541.          if(_loc3_._memberCount == 0)
  542.          {
  543.             delete this[_loc6_];
  544.             delete this.__radioGroups[_loc6_];
  545.          }
  546.          else if(_loc3_.selection == item)
  547.          {
  548.             delete _loc3_._selection;
  549.          }
  550.       }
  551.    }
  552.    function deinstallAllItems(Void)
  553.    {
  554.       for(var _loc2_ in this.__namedItems)
  555.       {
  556.          delete this[_loc2_];
  557.       }
  558.       delete this.__namedItems;
  559.       for(_loc2_ in this.__radioGroups)
  560.       {
  561.          delete this[_loc2_];
  562.       }
  563.       delete this.__radioGroups;
  564.    }
  565.    function getGroupSelection()
  566.    {
  567.       return this._selection;
  568.    }
  569.    function setGroupSelection(item)
  570.    {
  571.       this._selection = item;
  572.       for(var _loc4_ in this._members)
  573.       {
  574.          var _loc2_ = this._members[_loc4_];
  575.          _loc2_.attributes.selected = _loc2_ == item;
  576.       }
  577.       item.updateViews({eventName:"selectionChanged",node:item});
  578.    }
  579.    function onRowRelease(rowIndex)
  580.    {
  581.       if(!this.enabled || !this.selectable || !this.visible)
  582.       {
  583.          return undefined;
  584.       }
  585.       var _loc5_ = this.rows[rowIndex];
  586.       var _loc2_ = _loc5_.item;
  587.       if(_loc2_ != undefined && mx.controls.Menu.isItemEnabled(_loc2_))
  588.       {
  589.          var _loc10_ = _loc2_.attributes.type;
  590.          var _loc4_ = !_loc2_.hasChildNodes() && _loc10_ != "separator";
  591.          if(_loc4_)
  592.          {
  593.             this.hideAllMenus();
  594.          }
  595.          var _loc6_ = undefined;
  596.          var _loc3_ = this.getRootMenu();
  597.          if(_loc10_ == "check" || _loc10_ == "radio")
  598.          {
  599.             this.setMenuItemSelected(_loc2_,!mx.controls.Menu.isItemSelected(_loc2_));
  600.          }
  601.          if(_loc4_)
  602.          {
  603.             _loc3_.dispatchEvent({type:"change",menuBar:this.__menuBar,menu:_loc3_,menuItem:_loc2_,groupName:_loc6_});
  604.          }
  605.       }
  606.    }
  607.    function onRowPress(rowIndex)
  608.    {
  609.       var _loc3_ = this.rows[rowIndex].item;
  610.       if(mx.controls.Menu.isItemEnabled(_loc3_) && !_loc3_.hasChildNodes())
  611.       {
  612.          super.onRowPress(rowIndex);
  613.       }
  614.    }
  615.    function onRowRollOut(rowIndex)
  616.    {
  617.       if(!this.enabled || !this.selectable || !this.visible)
  618.       {
  619.          return undefined;
  620.       }
  621.       super.onRowRollOut(rowIndex);
  622.       var _loc4_ = this.rows[rowIndex].item;
  623.       if(_loc4_ != undefined)
  624.       {
  625.          var _loc5_ = this.getRootMenu();
  626.          _loc5_.dispatchEvent({type:"rollOut",menuBar:this.__menuBar,menu:this,menuItem:_loc4_});
  627.       }
  628.       var _loc3_ = this.__activeChildren[_loc4_.getID()];
  629.       if(_loc4_.hasChildNodes() > 0)
  630.       {
  631.          if(_loc3_.isOpening || _loc3_.isOpening == undefined)
  632.          {
  633.             this.cancelMenuDelay();
  634.             _loc3_.isOpening = false;
  635.          }
  636.          if(_loc3_.visible)
  637.          {
  638.             this.rows[rowIndex].drawRow(_loc4_,"selected",false);
  639.          }
  640.       }
  641.       else if(_loc3_.isClosing || _loc3_.isClosing == undefined)
  642.       {
  643.          this.cancelMenuDelay();
  644.          _loc3_.isClosing = false;
  645.       }
  646.       this.setTimeOut(this.__closeDelay,_loc4_.getID());
  647.    }
  648.    function onRowRollOver(rowIndex)
  649.    {
  650.       if(!this.enabled || !this.selectable || !this.visible)
  651.       {
  652.          return undefined;
  653.       }
  654.       var _loc2_ = this.rows[rowIndex];
  655.       var _loc8_ = _loc2_.item;
  656.       var _loc6_ = _loc8_.getID();
  657.       var _loc4_ = this.__activeChildren[this.__anchor];
  658.       var _loc5_ = this.__activeChildren[_loc6_];
  659.       this.clearSelected();
  660.       this.clearTimeOut();
  661.       this.__lastRowRolledOver = rowIndex;
  662.       if(this.anchorRow != undefined)
  663.       {
  664.          this.anchorRow.drawRow(this.anchorRow.item,"normal",false);
  665.          delete this.anchorRow;
  666.       }
  667.       if(this.__parentMenu)
  668.       {
  669.          var _loc3_ = this.__parentMenu.rows[this.__anchorIndex];
  670.          _loc3_.drawRow(_loc3_.item,"selected",false);
  671.          this.__parentMenu.anchorRow = _loc3_;
  672.       }
  673.       if(_loc5_.__activeChildren[_loc5_.__anchor].visible)
  674.       {
  675.          _loc5_.__activeChildren[_loc5_.__anchor].hide();
  676.       }
  677.       if(_loc4_.visible && this.__anchor != _loc6_)
  678.       {
  679.          _loc4_.isClosing = true;
  680.          this.setMenuDelay(this.__closeDelay,"closeSubMenu",{id:this.__anchor});
  681.       }
  682.       if(_loc8_ != undefined && mx.controls.Menu.isItemEnabled(_loc8_))
  683.       {
  684.          var _loc7_ = this.getRootMenu();
  685.          _loc7_.dispatchEvent({type:"rollOver",menuBar:this.__menuBar,menu:this,menuItem:_loc8_});
  686.          if(_loc8_.hasChildNodes() > 0)
  687.          {
  688.             this.anchorRow = _loc2_;
  689.             _loc2_.drawRow(_loc8_,"selected",false);
  690.             if(!_loc5_.visible)
  691.             {
  692.                _loc5_.isOpening = true;
  693.                this.setMenuDelay(this.__openDelay,"openSubMenu",{item:_loc8_,rowIndex:rowIndex});
  694.             }
  695.          }
  696.          else
  697.          {
  698.             _loc2_.drawRow(_loc8_,"highlighted",false);
  699.          }
  700.       }
  701.    }
  702.    function onRowDragOver(rowIndex)
  703.    {
  704.       var _loc4_ = this.__dataProvider.getItemAt(rowIndex + this.__vPosition);
  705.       if(mx.controls.Menu.isItemEnabled(_loc4_))
  706.       {
  707.          super.onRowDragOver(rowIndex);
  708.          this.onRowRollOver(rowIndex);
  709.       }
  710.    }
  711.    function __onMouseUp()
  712.    {
  713.       clearInterval(this.dragScrolling);
  714.       delete this.dragScrolling;
  715.       delete this.isPressed;
  716.       if(!this.selectable)
  717.       {
  718.          return undefined;
  719.       }
  720.       if(this.__wasVisible)
  721.       {
  722.          this.hide();
  723.       }
  724.       this.__wasVisible = false;
  725.    }
  726.    function setMenuDelay(delay, request, args)
  727.    {
  728.       if(this.__timer == null)
  729.       {
  730.          this.__timer = setInterval(this,"callMenuDelay",delay,request,args);
  731.       }
  732.       else
  733.       {
  734.          this.__delayQueue.push({delay:delay,request:request,args:args});
  735.       }
  736.    }
  737.    function callMenuDelay(request, args)
  738.    {
  739.       this[request](args);
  740.       this.clearMenuDelay();
  741.    }
  742.    function clearMenuDelay(Void)
  743.    {
  744.       clearInterval(this.__timer);
  745.       this.__timer = null;
  746.       this.runDelayQueue();
  747.    }
  748.    function cancelMenuDelay(Void)
  749.    {
  750.       var _loc2_ = this.__delayQueue.pop();
  751.       this.clearMenuDelay();
  752.    }
  753.    function runDelayQueue(Void)
  754.    {
  755.       if(this.__delayQueue.length == 0)
  756.       {
  757.          return undefined;
  758.       }
  759.       var _loc2_ = this.__delayQueue.shift();
  760.       var _loc4_ = _loc2_.delay;
  761.       var _loc5_ = _loc2_.request;
  762.       var _loc3_ = _loc2_.args;
  763.       this.setMenuDelay(_loc4_,_loc5_,_loc3_);
  764.    }
  765.    function setTimeOut(delay, id)
  766.    {
  767.       this.clearTimeOut();
  768.       this.__timeOut = setInterval(this,"callTimeOut",delay,id);
  769.    }
  770.    function clearTimeOut(Void)
  771.    {
  772.       clearInterval(this.__timeOut);
  773.       this.__timeOut = null;
  774.    }
  775.    function callTimeOut(Void)
  776.    {
  777.       var _loc2_ = this.__activeChildren[this.__anchor];
  778.       this.clearTimeOut();
  779.       if(!this.isMouseOverMenu() && _loc2_)
  780.       {
  781.          var _loc3_ = _loc2_.__anchorIndex;
  782.          var _loc5_ = this.__dataProvider.getItemAt(_loc3_ + this.__vPosition);
  783.          var _loc4_ = this.rows[_loc3_];
  784.          _loc4_.drawRow(_loc5_,"normal",false);
  785.          _loc2_.hide();
  786.          this.__delayQueue.length = 0;
  787.       }
  788.    }
  789.    function openSubMenu(o)
  790.    {
  791.       var _loc3_ = this.getRootMenu();
  792.       var _loc6_ = this.rows[o.rowIndex];
  793.       var _loc7_ = o.item;
  794.       var _loc0_ = null;
  795.       var _loc4_ = this.__anchor = _loc7_.getID();
  796.       var _loc2_ = _loc3_.__menuCache[_loc4_];
  797.       if(_loc2_ == undefined)
  798.       {
  799.          _loc2_ = mx.managers.PopUpManager.createPopUp(_loc3_,mx.controls.Menu,false,{__parentMenu:this,__anchorIndex:o.rowIndex,styleName:_loc3_},true);
  800.          _loc2_.labelField = _loc3_.__labelField;
  801.          _loc2_.labelFunction = _loc3_.__labelFunction;
  802.          _loc2_.iconField = _loc3_.__iconField;
  803.          _loc2_.iconFunction = _loc3_.__iconFunction;
  804.          _loc2_.wasJustCreated = true;
  805.          _loc2_.cellRenderer = _loc3_.__cellRenderer;
  806.          _loc2_.rowHeight = _loc3_.__rowHeight;
  807.          if(_loc3_.__menuCache == undefined)
  808.          {
  809.             _loc3_.__menuCache = new Object();
  810.             _loc3_.__menuCache[_loc3_.__menuDataProvider.getID()] = _loc3_;
  811.          }
  812.          if(this.__activeChildren == undefined)
  813.          {
  814.             this.__activeChildren = new Object();
  815.          }
  816.          _loc3_.__menuCache[_loc4_] = _loc2_;
  817.          this.__activeChildren[_loc4_] = _loc2_;
  818.          _loc2_.__dataProvider.addItemsAt(0,_loc7_.childNodes);
  819.          _loc2_.invUpdateSize = true;
  820.          _loc2_.invalidate();
  821.       }
  822.       _loc2_.__menuBar = this.__menuBar;
  823.       var _loc5_ = {x:0,y:0};
  824.       _loc6_.localToGlobal(_loc5_);
  825.       _loc2_.focusManager.lastFocus = undefined;
  826.       _loc2_.show(_loc5_.x + _loc6_.__width,_loc5_.y);
  827.       this.focusManager.lastFocus = undefined;
  828.       _loc2_.isOpening = false;
  829.    }
  830.    function closeSubMenu(o)
  831.    {
  832.       var _loc2_ = this.__activeChildren[o.id];
  833.       _loc2_.hide();
  834.       _loc2_.isClosing = false;
  835.    }
  836.    function moveSelBy(incr)
  837.    {
  838.       var _loc3_ = this.getSelectedIndex();
  839.       if(_loc3_ == undefined)
  840.       {
  841.          _loc3_ = -1;
  842.       }
  843.       var _loc2_ = _loc3_ + incr;
  844.       if(_loc2_ > this.__dataProvider.length - 1)
  845.       {
  846.          _loc2_ = 0;
  847.       }
  848.       else if(_loc2_ < 0)
  849.       {
  850.          _loc2_ = this.__dataProvider.length - 1;
  851.       }
  852.       this.wasKeySelected = true;
  853.       this.selectRow(_loc2_ - this.__vPosition,false);
  854.       var _loc4_ = this.__dataProvider.getItemAt(_loc2_ + this.__vPosition);
  855.       if(_loc4_.attributes.type == "separator")
  856.       {
  857.          this.moveSelBy(incr);
  858.       }
  859.    }
  860.    function keyDown(e)
  861.    {
  862.       if(this.__lastRowRolledOver != undefined)
  863.       {
  864.          this.selectedIndex = this.__lastRowRolledOver;
  865.          this.__lastRowRolledOver = undefined;
  866.       }
  867.       var _loc2_ = this.selectedItem;
  868.       if(Key.isDown(38))
  869.       {
  870.          var _loc3_ = this.getRootMenu();
  871.          var _loc4_ = _loc3_.__menuCache[_loc2_.getID()];
  872.          if(_loc2_.hasChildNodes() && _loc4_.visible)
  873.          {
  874.             this.supposedToLoseFocus = true;
  875.             Selection.setFocus(_loc4_);
  876.             _loc4_.selectedIndex = _loc4_.rows.length - 1;
  877.          }
  878.          else
  879.          {
  880.             this.moveSelBy(-1);
  881.          }
  882.       }
  883.       if(Key.isDown(40))
  884.       {
  885.          _loc3_ = this.getRootMenu();
  886.          _loc4_ = _loc3_.__menuCache[_loc2_.getID()];
  887.          if(_loc2_.hasChildNodes() && _loc4_.visible)
  888.          {
  889.             this.supposedToLoseFocus = true;
  890.             Selection.setFocus(_loc4_);
  891.             _loc4_.selectedIndex = 0;
  892.          }
  893.          else
  894.          {
  895.             this.moveSelBy(1);
  896.          }
  897.       }
  898.       if(Key.isDown(39))
  899.       {
  900.          if(_loc2_.hasChildNodes())
  901.          {
  902.             this.openSubMenu({item:_loc2_,rowIndex:this.selectedIndex});
  903.             _loc3_ = this.getRootMenu();
  904.             _loc4_ = _loc3_.__menuCache[_loc2_.getID()];
  905.             this.supposedToLoseFocus = true;
  906.             Selection.setFocus(_loc4_);
  907.             _loc4_.selectedIndex = 0;
  908.          }
  909.          else if(this.__menuBar)
  910.          {
  911.             this.supposedToLoseFocus = true;
  912.             Selection.setFocus(this.__menuBar);
  913.             this.__menuBar.keyDown(e);
  914.          }
  915.       }
  916.       if(Key.isDown(37))
  917.       {
  918.          if(this.__parentMenu)
  919.          {
  920.             this.supposedToLoseFocus = true;
  921.             this.hide();
  922.             Selection.setFocus(this.__parentMenu);
  923.          }
  924.          else if(this.__menuBar)
  925.          {
  926.             this.supposedToLoseFocus = true;
  927.             Selection.setFocus(this.__menuBar);
  928.             this.__menuBar.keyDown(e);
  929.          }
  930.       }
  931.       if(Key.isDown(13) || Key.isDown(32))
  932.       {
  933.          if(_loc2_.hasChildNodes())
  934.          {
  935.             this.openSubMenu({item:_loc2_,rowIndex:this.selectedIndex});
  936.             _loc3_ = this.getRootMenu();
  937.             _loc4_ = _loc3_.__menuCache[_loc2_.getID()];
  938.             _loc4_.selectedIndex = 0;
  939.          }
  940.          else
  941.          {
  942.             this.onRowRelease(this.selectedIndex);
  943.          }
  944.       }
  945.       if(Key.isDown(27) || Key.isDown(9))
  946.       {
  947.          this.hideAllMenus();
  948.       }
  949.    }
  950.    function hideAllMenus(Void)
  951.    {
  952.       this.getRootMenu().hide();
  953.    }
  954.    function isMouseOverMenu(Void)
  955.    {
  956.       var _loc6_ = _root._xmouse;
  957.       var _loc5_ = _root._ymouse;
  958.       if(this.border_mc.hitTest(_loc6_,_loc5_))
  959.       {
  960.          return true;
  961.       }
  962.       var _loc4_ = this.getRootMenu();
  963.       for(var _loc7_ in _loc4_.__menuCache)
  964.       {
  965.          var _loc3_ = _loc4_.__menuCache[_loc7_];
  966.          if(_loc3_.visible && _loc3_.border_mc.hitTest(_loc6_,_loc5_))
  967.          {
  968.             return true;
  969.          }
  970.       }
  971.       return false;
  972.    }
  973.    function getRootMenu(Void)
  974.    {
  975.       var _loc2_ = this;
  976.       while(_loc2_.__parentMenu != undefined)
  977.       {
  978.          _loc2_ = _loc2_.__parentMenu;
  979.       }
  980.       return _loc2_;
  981.    }
  982. }
  983.