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

  1. class mx.skins.halo.FocusRect extends mx.skins.SkinElement
  2. {
  3.    var boundingBox_mc;
  4.    var drawRoundRect;
  5.    var removeEventListener;
  6.    var addEventListener;
  7.    var getStyle;
  8.    var width;
  9.    var height;
  10.    var x;
  11.    var y;
  12.    static var classConstructed = mx.skins.halo.FocusRect.classConstruct();
  13.    static var DefaultsDependency = mx.skins.halo.Defaults;
  14.    static var UIComponentDependency = mx.core.UIComponent;
  15.    function FocusRect()
  16.    {
  17.       super();
  18.       this.boundingBox_mc._visible = false;
  19.       this.boundingBox_mc._width = this.boundingBox_mc._height = 0;
  20.    }
  21.    function draw(o)
  22.    {
  23.       o.adjustFocusRect();
  24.    }
  25.    function setSize(w, h, r, a, rectCol)
  26.    {
  27.       this._xscale = this._yscale = 100;
  28.       this.clear();
  29.       if(typeof r == "object")
  30.       {
  31.          r.br = r.br <= 2 ? 0 : r.br - 2;
  32.          r.bl = r.bl <= 2 ? 0 : r.bl - 2;
  33.          r.tr = r.tr <= 2 ? 0 : r.tr - 2;
  34.          r.tl = r.tl <= 2 ? 0 : r.tl - 2;
  35.          this.beginFill(rectCol,a * 0.3);
  36.          this.drawRoundRect(0,0,w,h,r);
  37.          this.drawRoundRect(2,2,w - 4,h - 4,r);
  38.          this.endFill();
  39.          r.br = r.br <= 1 ? 0 : r.br + 1;
  40.          r.bl = r.bl <= 1 ? 0 : r.bl + 1;
  41.          r.tr = r.tr <= 1 ? 0 : r.tr + 1;
  42.          r.tl = r.tl <= 1 ? 0 : r.tl + 1;
  43.          this.beginFill(rectCol,a * 0.3);
  44.          this.drawRoundRect(1,1,w - 2,h - 2,r);
  45.          r.br = r.br <= 1 ? 0 : r.br - 1;
  46.          r.bl = r.bl <= 1 ? 0 : r.bl - 1;
  47.          r.tr = r.tr <= 1 ? 0 : r.tr - 1;
  48.          r.tl = r.tl <= 1 ? 0 : r.tl - 1;
  49.          this.drawRoundRect(2,2,w - 4,h - 4,r);
  50.          this.endFill();
  51.       }
  52.       else
  53.       {
  54.          var _loc5_ = undefined;
  55.          if(r != 0)
  56.          {
  57.             _loc5_ = r - 2;
  58.          }
  59.          else
  60.          {
  61.             _loc5_ = 0;
  62.          }
  63.          this.beginFill(rectCol,a * 0.3);
  64.          this.drawRoundRect(0,0,w,h,r);
  65.          this.drawRoundRect(2,2,w - 4,h - 4,_loc5_);
  66.          this.endFill();
  67.          this.beginFill(rectCol,a * 0.3);
  68.          if(r != 0)
  69.          {
  70.             _loc5_ = r - 2;
  71.             r -= 1;
  72.          }
  73.          else
  74.          {
  75.             _loc5_ = 0;
  76.             r = 0;
  77.          }
  78.          this.drawRoundRect(1,1,w - 2,h - 2,r);
  79.          this.drawRoundRect(2,2,w - 4,h - 4,_loc5_);
  80.          this.endFill();
  81.       }
  82.    }
  83.    function handleEvent(e)
  84.    {
  85.       if(e.type == "unload")
  86.       {
  87.          this._visible = true;
  88.       }
  89.       else if(e.type == "resize")
  90.       {
  91.          e.target.adjustFocusRect();
  92.       }
  93.       else if(e.type == "move")
  94.       {
  95.          e.target.adjustFocusRect();
  96.       }
  97.    }
  98.    static function classConstruct()
  99.    {
  100.       mx.core.UIComponent.prototype.drawFocus = function(focused)
  101.       {
  102.          var _loc2_ = this._parent.focus_mc;
  103.          if(!focused)
  104.          {
  105.             _loc2_._visible = false;
  106.             this.removeEventListener("unload",_loc2_);
  107.             this.removeEventListener("move",_loc2_);
  108.             this.removeEventListener("resize",_loc2_);
  109.          }
  110.          else
  111.          {
  112.             if(_loc2_ == undefined)
  113.             {
  114.                _loc2_ = this._parent.createChildAtDepth("FocusRect",mx.managers.DepthManager.kTop);
  115.                _loc2_.tabEnabled = false;
  116.                this._parent.focus_mc = _loc2_;
  117.             }
  118.             else
  119.             {
  120.                _loc2_._visible = true;
  121.             }
  122.             _loc2_.draw(this);
  123.             if(_loc2_.getDepth() < this.getDepth())
  124.             {
  125.                _loc2_.setDepthAbove(this);
  126.             }
  127.             this.addEventListener("unload",_loc2_);
  128.             this.addEventListener("move",_loc2_);
  129.             this.addEventListener("resize",_loc2_);
  130.          }
  131.       };
  132.       mx.core.UIComponent.prototype.adjustFocusRect = function()
  133.       {
  134.          var _loc2_ = this.getStyle("themeColor");
  135.          if(_loc2_ == undefined)
  136.          {
  137.             _loc2_ = 8453965;
  138.          }
  139.          var _loc3_ = this._parent.focus_mc;
  140.          _loc3_.setSize(this.width + 4,this.height + 4,0,100,_loc2_);
  141.          _loc3_.move(this.x - 2,this.y - 2);
  142.       };
  143.       TextField.prototype.drawFocus = mx.core.UIComponent.prototype.drawFocus;
  144.       TextField.prototype.adjustFocusRect = mx.core.UIComponent.prototype.adjustFocusRect;
  145.       mx.skins.halo.FocusRect.prototype.drawRoundRect = mx.skins.halo.Defaults.prototype.drawRoundRect;
  146.       return true;
  147.    }
  148. }
  149.