home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / mallcrawl.swf / scripts / __Packages / mx / managers / FocusManager.as < prev    next >
Encoding:
Text File  |  2007-09-28  |  21.8 KB  |  714 lines

  1. class mx.managers.FocusManager extends mx.core.UIComponent
  2. {
  3.    var __defaultPushButton;
  4.    var defPushButton;
  5.    var form;
  6.    var tabCapture;
  7.    var lastMouse;
  8.    var lastFocus;
  9.    var lastSelFocus;
  10.    var _searchKey;
  11.    var _lastTarget;
  12.    var _firstNode;
  13.    var _nextIsNext;
  14.    var _nextNode;
  15.    var _lastx;
  16.    var _prevNode;
  17.    var _needPrev;
  18.    var _foundList;
  19.    var _prevObj;
  20.    var _nextObj;
  21.    var _firstObj;
  22.    var _lastObj;
  23.    var _lastNode;
  24.    var lastTabFocus;
  25.    static var symbolName = "FocusManager";
  26.    static var symbolOwner = mx.managers.FocusManager;
  27.    static var version = "2.0.2.126";
  28.    var className = "FocusManager";
  29.    var bNeedFocus = false;
  30.    var bDrawFocus = false;
  31.    var defaultPushButtonEnabled = true;
  32.    var activated = true;
  33.    static var initialized = false;
  34.    static var UIObjectExtensionsDependency = mx.core.ext.UIObjectExtensions;
  35.    function FocusManager()
  36.    {
  37.       super();
  38.    }
  39.    function get defaultPushButton()
  40.    {
  41.       return this.__defaultPushButton;
  42.    }
  43.    function set defaultPushButton(x)
  44.    {
  45.       if(x != this.__defaultPushButton)
  46.       {
  47.          this.__defaultPushButton.emphasized = false;
  48.          this.__defaultPushButton = x;
  49.          this.defPushButton = x;
  50.          x.emphasized = true;
  51.       }
  52.    }
  53.    function getMaxTabIndex(o)
  54.    {
  55.       var _loc3_ = 0;
  56.       var _loc6_ = undefined;
  57.       for(_loc6_ in o)
  58.       {
  59.          var _loc2_ = o[_loc6_];
  60.          if(_loc2_._parent == o)
  61.          {
  62.             if(_loc2_.tabIndex != undefined)
  63.             {
  64.                if(_loc2_.tabIndex > _loc3_)
  65.                {
  66.                   _loc3_ = _loc2_.tabIndex;
  67.                }
  68.             }
  69.             if(_loc2_.tabChildren == true)
  70.             {
  71.                var _loc4_ = this.getMaxTabIndex(_loc2_);
  72.                if(_loc4_ > _loc3_)
  73.                {
  74.                   _loc3_ = _loc4_;
  75.                }
  76.             }
  77.          }
  78.       }
  79.       return _loc3_;
  80.    }
  81.    function getNextTabIndex(Void)
  82.    {
  83.       return this.getMaxTabIndex(this.form) + 1;
  84.    }
  85.    function get nextTabIndex()
  86.    {
  87.       return this.getNextTabIndex();
  88.    }
  89.    function relocate(Void)
  90.    {
  91.       var _loc2_ = mx.managers.SystemManager.screen;
  92.       this.move(_loc2_.x - 1,_loc2_.y - 1);
  93.    }
  94.    function init(Void)
  95.    {
  96.       super.init();
  97.       this.tabEnabled = false;
  98.       this._width = this._height = 1;
  99.       this._x = this._y = -1;
  100.       this._alpha = 0;
  101.       this._parent.focusManager = this;
  102.       this._parent.tabChildren = true;
  103.       this._parent.tabEnabled = false;
  104.       this.form = this._parent;
  105.       this._parent.addEventListener("hide",this);
  106.       this._parent.addEventListener("reveal",this);
  107.       mx.managers.SystemManager.init();
  108.       mx.managers.SystemManager.addFocusManager(this.form);
  109.       this.tabCapture.tabIndex = 0;
  110.       this.watch("enabled",this.enabledChanged);
  111.       Selection.addListener(this);
  112.       this.lastMouse = new Object();
  113.       _global.ASSetPropFlags(this._parent,"focusManager",1);
  114.       _global.ASSetPropFlags(this._parent,"tabChildren",1);
  115.       _global.ASSetPropFlags(this._parent,"tabEnabled",1);
  116.    }
  117.    function enabledChanged(id, oldValue, newValue)
  118.    {
  119.       this._visible = newValue;
  120.       return newValue;
  121.    }
  122.    function activate(Void)
  123.    {
  124.       Key.addListener(this);
  125.       this.activated = this._visible = true;
  126.       if(this.lastFocus != undefined)
  127.       {
  128.          this.bNeedFocus = true;
  129.          if(!mx.managers.SystemManager.isMouseDown)
  130.          {
  131.             this.doLater(this,"restoreFocus");
  132.          }
  133.       }
  134.    }
  135.    function deactivate(Void)
  136.    {
  137.       Key.removeListener(this);
  138.       this.activated = this._visible = false;
  139.       var _loc2_ = this.getSelectionFocus();
  140.       var _loc3_ = this.getActualFocus(_loc2_);
  141.       if(this.isOurFocus(_loc3_))
  142.       {
  143.          this.lastSelFocus = _loc2_;
  144.          this.lastFocus = _loc3_;
  145.       }
  146.       this.cancelAllDoLaters();
  147.    }
  148.    function isOurFocus(o)
  149.    {
  150.       if(o.focusManager == this)
  151.       {
  152.          return true;
  153.       }
  154.       while(o != undefined)
  155.       {
  156.          if(o.focusManager != undefined)
  157.          {
  158.             return false;
  159.          }
  160.          if(o._parent == this._parent)
  161.          {
  162.             return true;
  163.          }
  164.          o = o._parent;
  165.       }
  166.       return false;
  167.    }
  168.    function onSetFocus(o, n)
  169.    {
  170.       if(n == null)
  171.       {
  172.          if(this.activated)
  173.          {
  174.             this.bNeedFocus = true;
  175.          }
  176.       }
  177.       else
  178.       {
  179.          var _loc2_ = this.getFocus();
  180.          if(this.isOurFocus(_loc2_))
  181.          {
  182.             this.bNeedFocus = false;
  183.             this.lastFocus = _loc2_;
  184.             this.lastSelFocus = n;
  185.          }
  186.       }
  187.    }
  188.    function restoreFocus(Void)
  189.    {
  190.       var _loc2_ = this.lastSelFocus.hscroll;
  191.       if(_loc2_ != undefined)
  192.       {
  193.          var _loc5_ = this.lastSelFocus.scroll;
  194.          var _loc4_ = this.lastSelFocus.background;
  195.       }
  196.       this.lastFocus.setFocus();
  197.       var _loc3_ = Selection;
  198.       Selection.setSelection(_loc3_.lastBeginIndex,_loc3_.lastEndIndex);
  199.       if(_loc2_ != undefined)
  200.       {
  201.          this.lastSelFocus.scroll = _loc5_;
  202.          this.lastSelFocus.hscroll = _loc2_;
  203.          this.lastSelFocus.background = _loc4_;
  204.       }
  205.    }
  206.    function onUnload(Void)
  207.    {
  208.       mx.managers.SystemManager.removeFocusManager(this.form);
  209.    }
  210.    function setFocus(o)
  211.    {
  212.       if(o == null)
  213.       {
  214.          Selection.setFocus(null);
  215.       }
  216.       else if(o.setFocus == undefined)
  217.       {
  218.          Selection.setFocus(o);
  219.       }
  220.       else
  221.       {
  222.          o.setFocus();
  223.       }
  224.    }
  225.    function getActualFocus(o)
  226.    {
  227.       var _loc1_ = o._parent;
  228.       while(_loc1_ != undefined)
  229.       {
  230.          if(_loc1_.focusTextField != undefined)
  231.          {
  232.             while(_loc1_.focusTextField != undefined)
  233.             {
  234.                o = _loc1_;
  235.                _loc1_ = _loc1_._parent;
  236.                if(_loc1_ == undefined)
  237.                {
  238.                   return undefined;
  239.                }
  240.                if(_loc1_.focusTextField == undefined)
  241.                {
  242.                   return o;
  243.                }
  244.             }
  245.          }
  246.          if(_loc1_.tabEnabled != true)
  247.          {
  248.             return o;
  249.          }
  250.          o = _loc1_;
  251.          _loc1_ = o._parent;
  252.       }
  253.       return undefined;
  254.    }
  255.    function getSelectionFocus()
  256.    {
  257.       var m = Selection.getFocus();
  258.       var o = eval(m);
  259.       return o;
  260.    }
  261.    function getFocus(Void)
  262.    {
  263.       var _loc2_ = this.getSelectionFocus();
  264.       return this.getActualFocus(_loc2_);
  265.    }
  266.    function walkTree(p, index, groupName, dir, lookup, firstChild)
  267.    {
  268.       var _loc5_ = true;
  269.       var _loc11_ = undefined;
  270.       for(_loc11_ in p)
  271.       {
  272.          var _loc2_ = p[_loc11_];
  273.          if(_loc2_._parent == p && _loc2_.enabled != false && _loc2_._visible != false && (_loc2_.tabEnabled == true || _loc2_.tabEnabled != false && (_loc2_.onPress != undefined || _loc2_.onRelease != undefined || _loc2_.onReleaseOutside != undefined || _loc2_.onDragOut != undefined || _loc2_.onDragOver != undefined || _loc2_.onRollOver != undefined || _loc2_.onRollOut != undefined || _loc2_ instanceof TextField)))
  274.          {
  275.             if(_loc2_._searchKey == this._searchKey)
  276.             {
  277.                continue;
  278.             }
  279.             _loc2_._searchKey = this._searchKey;
  280.             if(_loc2_ != this._lastTarget)
  281.             {
  282.                if((_loc2_.groupName != undefined || groupName != undefined) && _loc2_.groupName == groupName)
  283.                {
  284.                   continue;
  285.                }
  286.                if(_loc2_ instanceof TextField && _loc2_.selectable == false)
  287.                {
  288.                   continue;
  289.                }
  290.                if(_loc5_ || _loc2_.groupName != undefined && _loc2_.groupName == this._firstNode.groupName && _loc2_.selected == true)
  291.                {
  292.                   if(firstChild)
  293.                   {
  294.                      this._firstNode = _loc2_;
  295.                      firstChild = false;
  296.                   }
  297.                }
  298.                if(this._nextIsNext == true)
  299.                {
  300.                   if(_loc2_.groupName != undefined && _loc2_.groupName == this._nextNode.groupName && _loc2_.selected == true || this._nextNode == undefined && (_loc2_.groupName == undefined || _loc2_.groupName != undefined && _loc2_.groupName != groupName))
  301.                   {
  302.                      this._nextNode = _loc2_;
  303.                   }
  304.                }
  305.                if(_loc2_.groupName == undefined || groupName != _loc2_.groupName)
  306.                {
  307.                   if(!(this._lastx.groupName != undefined && _loc2_.groupName == this._lastx.groupName && this._lastx.selected == true))
  308.                   {
  309.                      this._lastx = _loc2_;
  310.                   }
  311.                }
  312.             }
  313.             else
  314.             {
  315.                this._prevNode = this._lastx;
  316.                this._needPrev = false;
  317.                this._nextIsNext = true;
  318.             }
  319.             if(_loc2_.tabIndex != undefined)
  320.             {
  321.                if(_loc2_.tabIndex == index)
  322.                {
  323.                   if(this._foundList[_loc2_._name] == undefined)
  324.                   {
  325.                      if(this._needPrev)
  326.                      {
  327.                         this._prevObj = _loc2_;
  328.                         this._needPrev = false;
  329.                      }
  330.                      this._nextObj = _loc2_;
  331.                   }
  332.                }
  333.                if(dir && _loc2_.tabIndex > index)
  334.                {
  335.                   if(this._nextObj == undefined || this._nextObj.tabIndex > _loc2_.tabIndex && (_loc2_.groupName == undefined || this._nextObj.groupName == undefined || _loc2_.groupName != this._nextObj.groupName) || this._nextObj.groupName != undefined && this._nextObj.groupName == _loc2_.groupName && this._nextObj.selected != true && (_loc2_.selected == true || this._nextObj.tabIndex > _loc2_.tabIndex))
  336.                   {
  337.                      this._nextObj = _loc2_;
  338.                   }
  339.                }
  340.                else if(!dir && _loc2_.tabIndex < index)
  341.                {
  342.                   if(this._prevObj == undefined || this._prevObj.tabIndex < _loc2_.tabIndex && (_loc2_.groupName == undefined || this._prevObj.groupName == undefined || _loc2_.groupName != this._prevObj.groupName) || this._prevObj.groupName != undefined && this._prevObj.groupName == _loc2_.groupName && this._prevObj.selected != true && (_loc2_.selected == true || this._prevObj.tabIndex < _loc2_.tabIndex))
  343.                   {
  344.                      this._prevObj = _loc2_;
  345.                   }
  346.                }
  347.                if(this._firstObj == undefined || _loc2_.tabIndex < this._firstObj.tabIndex && (_loc2_.groupName == undefined || this._firstObj.groupName == undefined || _loc2_.groupName != this._firstObj.groupName) || this._firstObj.groupName != undefined && this._firstObj.groupName == _loc2_.groupName && this._firstObj.selected != true && (_loc2_.selected == true || _loc2_.tabIndex < this._firstObj.tabIndex))
  348.                {
  349.                   this._firstObj = _loc2_;
  350.                }
  351.                if(this._lastObj == undefined || _loc2_.tabIndex > this._lastObj.tabIndex && (_loc2_.groupName == undefined || this._lastObj.groupName == undefined || _loc2_.groupName != this._lastObj.groupName) || this._lastObj.groupName != undefined && this._lastObj.groupName == _loc2_.groupName && this._lastObj.selected != true && (_loc2_.selected == true || _loc2_.tabIndex > this._lastObj.tabIndex))
  352.                {
  353.                   this._lastObj = _loc2_;
  354.                }
  355.             }
  356.             if(_loc2_.tabChildren)
  357.             {
  358.                this.getTabCandidateFromChildren(_loc2_,index,groupName,dir,_loc5_ && firstChild);
  359.             }
  360.             _loc5_ = false;
  361.          }
  362.          else if(_loc2_._parent == p && _loc2_.tabChildren == true && _loc2_._visible != false)
  363.          {
  364.             if(_loc2_ == this._lastTarget)
  365.             {
  366.                if(_loc2_._searchKey == this._searchKey)
  367.                {
  368.                   continue;
  369.                }
  370.                _loc2_._searchKey = this._searchKey;
  371.                if(this._prevNode == undefined)
  372.                {
  373.                   var _loc3_ = this._lastx;
  374.                   var _loc7_ = false;
  375.                   while(_loc3_ != undefined)
  376.                   {
  377.                      if(_loc3_ == _loc2_)
  378.                      {
  379.                         _loc7_ = true;
  380.                         break;
  381.                      }
  382.                      _loc3_ = _loc3_._parent;
  383.                   }
  384.                   if(_loc7_ == false)
  385.                   {
  386.                      this._prevNode = this._lastx;
  387.                   }
  388.                }
  389.                this._needPrev = false;
  390.                if(this._nextNode == undefined)
  391.                {
  392.                   this._nextIsNext = true;
  393.                }
  394.             }
  395.             else if(!(_loc2_.focusManager != undefined && _loc2_.focusManager._parent == _loc2_))
  396.             {
  397.                if(_loc2_._searchKey == this._searchKey)
  398.                {
  399.                   continue;
  400.                }
  401.                _loc2_._searchKey = this._searchKey;
  402.                this.getTabCandidateFromChildren(_loc2_,index,groupName,dir,_loc5_ && firstChild);
  403.             }
  404.             _loc5_ = false;
  405.          }
  406.       }
  407.       this._lastNode = this._lastx;
  408.       if(lookup)
  409.       {
  410.          if(p._parent != undefined)
  411.          {
  412.             if(p != this._parent)
  413.             {
  414.                if(this._prevNode == undefined && dir)
  415.                {
  416.                   this._needPrev = true;
  417.                }
  418.                else if(this._nextNode == undefined && !dir)
  419.                {
  420.                   this._nextIsNext = false;
  421.                }
  422.                this._lastTarget = this._lastTarget._parent;
  423.                this.getTabCandidate(p._parent,index,groupName,dir,true);
  424.             }
  425.          }
  426.       }
  427.    }
  428.    function getTabCandidate(o, index, groupName, dir, firstChild)
  429.    {
  430.       var _loc2_ = undefined;
  431.       var _loc3_ = true;
  432.       if(o == this._parent)
  433.       {
  434.          _loc2_ = o;
  435.          _loc3_ = false;
  436.       }
  437.       else
  438.       {
  439.          _loc2_ = o._parent;
  440.          if(_loc2_ == undefined)
  441.          {
  442.             _loc2_ = o;
  443.             _loc3_ = false;
  444.          }
  445.       }
  446.       this.walkTree(_loc2_,index,groupName,dir,_loc3_,firstChild);
  447.    }
  448.    function getTabCandidateFromChildren(o, index, groupName, dir, firstChild)
  449.    {
  450.       this.walkTree(o,index,groupName,dir,false,firstChild);
  451.    }
  452.    function getFocusManagerFromObject(o)
  453.    {
  454.       while(o != undefined)
  455.       {
  456.          if(o.focusManager != undefined)
  457.          {
  458.             return o.focusManager;
  459.          }
  460.          o = o._parent;
  461.       }
  462.       return undefined;
  463.    }
  464.    function tabHandler(Void)
  465.    {
  466.       this.bDrawFocus = true;
  467.       var _loc5_ = this.getSelectionFocus();
  468.       var _loc4_ = this.getActualFocus(_loc5_);
  469.       if(_loc4_ != _loc5_)
  470.       {
  471.          _loc5_ = _loc4_;
  472.       }
  473.       if(this.getFocusManagerFromObject(_loc5_) != this)
  474.       {
  475.          _loc5_ == undefined;
  476.       }
  477.       if(_loc5_ == undefined)
  478.       {
  479.          _loc5_ = this.form;
  480.       }
  481.       else if(_loc5_.tabIndex != undefined)
  482.       {
  483.          if(this._foundList != undefined || this._foundList.tabIndex != _loc5_.tabIndex)
  484.          {
  485.             this._foundList = new Object();
  486.             this._foundList.tabIndex = _loc5_.tabIndex;
  487.          }
  488.          this._foundList[_loc5_._name] = _loc5_;
  489.       }
  490.       var _loc3_ = Key.isDown(16) != true;
  491.       this._searchKey = getTimer();
  492.       this._needPrev = true;
  493.       this._nextIsNext = false;
  494.       this._lastx = undefined;
  495.       this._firstNode = undefined;
  496.       this._lastNode = undefined;
  497.       this._nextNode = undefined;
  498.       this._prevNode = undefined;
  499.       this._firstObj = undefined;
  500.       this._lastObj = undefined;
  501.       this._nextObj = undefined;
  502.       this._prevObj = undefined;
  503.       this._lastTarget = _loc5_;
  504.       var _loc6_ = _loc5_;
  505.       this.getTabCandidate(_loc6_,_loc5_.tabIndex != undefined ? _loc5_.tabIndex : 0,_loc5_.groupName,_loc3_,true);
  506.       var _loc2_ = undefined;
  507.       if(_loc3_)
  508.       {
  509.          if(this._nextObj != undefined)
  510.          {
  511.             _loc2_ = this._nextObj;
  512.          }
  513.          else
  514.          {
  515.             _loc2_ = this._firstObj;
  516.          }
  517.       }
  518.       else if(this._prevObj != undefined)
  519.       {
  520.          _loc2_ = this._prevObj;
  521.       }
  522.       else
  523.       {
  524.          _loc2_ = this._lastObj;
  525.       }
  526.       if(_loc2_.tabIndex != _loc5_.tabIndex)
  527.       {
  528.          this._foundList = new Object();
  529.          this._foundList.tabIndex = _loc2_.tabIndex;
  530.          this._foundList[_loc2_._name] = _loc2_;
  531.       }
  532.       else
  533.       {
  534.          if(this._foundList == undefined)
  535.          {
  536.             this._foundList = new Object();
  537.             this._foundList.tabIndex = _loc2_.tabIndex;
  538.          }
  539.          this._foundList[_loc2_._name] = _loc2_;
  540.       }
  541.       if(_loc2_ == undefined)
  542.       {
  543.          if(_loc3_ == false)
  544.          {
  545.             if(this._nextNode != undefined)
  546.             {
  547.                _loc2_ = this._nextNode;
  548.             }
  549.             else
  550.             {
  551.                _loc2_ = this._firstNode;
  552.             }
  553.          }
  554.          else if(this._prevNode == undefined || _loc5_ == this.form)
  555.          {
  556.             _loc2_ = this._lastNode;
  557.          }
  558.          else
  559.          {
  560.             _loc2_ = this._prevNode;
  561.          }
  562.       }
  563.       if(_loc2_ == undefined)
  564.       {
  565.          return undefined;
  566.       }
  567.       this.lastTabFocus = _loc2_;
  568.       this.setFocus(_loc2_);
  569.       if(_loc2_.emphasized != undefined)
  570.       {
  571.          if(this.defPushButton != undefined)
  572.          {
  573.             _loc5_ = this.defPushButton;
  574.             this.defPushButton = _loc2_;
  575.             _loc5_.emphasized = false;
  576.             _loc2_.emphasized = true;
  577.          }
  578.       }
  579.       else if(this.defPushButton != undefined && this.defPushButton != this.__defaultPushButton)
  580.       {
  581.          _loc5_ = this.defPushButton;
  582.          this.defPushButton = this.__defaultPushButton;
  583.          _loc5_.emphasized = false;
  584.          this.__defaultPushButton.emphasized = true;
  585.       }
  586.    }
  587.    function onKeyDown(Void)
  588.    {
  589.       mx.managers.SystemManager.idleFrames = 0;
  590.       if(this.defaultPushButtonEnabled)
  591.       {
  592.          if(Key.getCode() == 13)
  593.          {
  594.             if(this.defaultPushButton != undefined)
  595.             {
  596.                this.doLater(this,"sendDefaultPushButtonEvent");
  597.             }
  598.          }
  599.       }
  600.    }
  601.    function sendDefaultPushButtonEvent(Void)
  602.    {
  603.       this.defPushButton.dispatchEvent({type:"click"});
  604.    }
  605.    function getMousedComponentFromChildren(x, y, o)
  606.    {
  607.       for(var _loc7_ in o)
  608.       {
  609.          var _loc2_ = o[_loc7_];
  610.          if(_loc2_._visible && _loc2_.enabled && _loc2_._parent == o && _loc2_._searchKey != this._searchKey)
  611.          {
  612.             _loc2_._searchKey = this._searchKey;
  613.             if(_loc2_.hitTest(x,y,true))
  614.             {
  615.                if(_loc2_.onPress != undefined || _loc2_.onRelease != undefined)
  616.                {
  617.                   return _loc2_;
  618.                }
  619.                var _loc3_ = this.getMousedComponentFromChildren(x,y,_loc2_);
  620.                if(_loc3_ != undefined)
  621.                {
  622.                   return _loc3_;
  623.                }
  624.                return _loc2_;
  625.             }
  626.          }
  627.       }
  628.       return undefined;
  629.    }
  630.    function mouseActivate(Void)
  631.    {
  632.       if(!this.bNeedFocus)
  633.       {
  634.          return undefined;
  635.       }
  636.       this._searchKey = getTimer();
  637.       var _loc2_ = this.getMousedComponentFromChildren(this.lastMouse.x,this.lastMouse.y,this.form);
  638.       if(_loc2_ instanceof mx.core.UIComponent)
  639.       {
  640.          return undefined;
  641.       }
  642.       _loc2_ = this.findFocusFromObject(_loc2_);
  643.       if(_loc2_ == this.lastFocus)
  644.       {
  645.          return undefined;
  646.       }
  647.       if(_loc2_ == undefined)
  648.       {
  649.          this.doLater(this,"restoreFocus");
  650.          return undefined;
  651.       }
  652.       var _loc3_ = _loc2_.hscroll;
  653.       if(_loc3_ != undefined)
  654.       {
  655.          var _loc6_ = _loc2_.scroll;
  656.          var _loc5_ = _loc2_.background;
  657.       }
  658.       this.setFocus(_loc2_);
  659.       var _loc4_ = Selection;
  660.       Selection.setSelection(_loc4_.lastBeginIndex,_loc4_.lastEndIndex);
  661.       if(_loc3_ != undefined)
  662.       {
  663.          _loc2_.scroll = _loc6_;
  664.          _loc2_.hscroll = _loc3_;
  665.          _loc2_.background = _loc5_;
  666.       }
  667.    }
  668.    function _onMouseDown(Void)
  669.    {
  670.       this.bDrawFocus = false;
  671.       if(this.lastFocus != undefined)
  672.       {
  673.          this.lastFocus.drawFocus(false);
  674.       }
  675.       mx.managers.SystemManager.idleFrames = 0;
  676.       var _loc3_ = Selection;
  677.       _loc3_.lastBeginIndex = Selection.getBeginIndex();
  678.       _loc3_.lastEndIndex = Selection.getEndIndex();
  679.       this.lastMouse.x = _root._xmouse;
  680.       this.lastMouse.y = _root._ymouse;
  681.       _root.localToGlobal(this.lastMouse);
  682.    }
  683.    function onMouseUp(Void)
  684.    {
  685.       if(this._visible)
  686.       {
  687.          this.doLater(this,"mouseActivate");
  688.       }
  689.    }
  690.    function handleEvent(e)
  691.    {
  692.       if(e.type == "reveal")
  693.       {
  694.          mx.managers.SystemManager.activate(this.form);
  695.       }
  696.       else
  697.       {
  698.          mx.managers.SystemManager.deactivate(this.form);
  699.       }
  700.    }
  701.    static function enableFocusManagement()
  702.    {
  703.       if(!mx.managers.FocusManager.initialized)
  704.       {
  705.          mx.managers.FocusManager.initialized = true;
  706.          Object.registerClass("FocusManager",mx.managers.FocusManager);
  707.          if(_root.focusManager == undefined)
  708.          {
  709.             _root.createClassObject(mx.managers.FocusManager,"focusManager",mx.managers.DepthManager.highestDepth--);
  710.          }
  711.       }
  712.    }
  713. }
  714.