home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 2010 Software/Programs / PCGuia_programas.iso / Software / Utils / Livebrush / Install-LivebrushLite.air / livebrush.swf / scripts / fl / controls / Button.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  3.3 KB  |  115 lines

  1. package fl.controls
  2. {
  3.    import fl.core.InvalidationType;
  4.    import fl.core.UIComponent;
  5.    import fl.managers.IFocusManagerComponent;
  6.    import flash.display.DisplayObject;
  7.    
  8.    [Embed(source="/_assets/assets.swf", symbol="symbol260")]
  9.    public class Button extends LabelButton implements IFocusManagerComponent
  10.    {
  11.       public static var createAccessibilityImplementation:Function;
  12.       
  13.       private static var defaultStyles:Object = {
  14.          "emphasizedSkin":"Button_emphasizedSkin",
  15.          "emphasizedPadding":2
  16.       };
  17.       
  18.       protected var _emphasized:Boolean = false;
  19.       
  20.       protected var emphasizedBorder:DisplayObject;
  21.       
  22.       public function Button()
  23.       {
  24.          super();
  25.       }
  26.       
  27.       public static function getStyleDefinition() : Object
  28.       {
  29.          return UIComponent.mergeStyles(LabelButton.getStyleDefinition(),defaultStyles);
  30.       }
  31.       
  32.       public function set emphasized(param1:Boolean) : void
  33.       {
  34.          _emphasized = param1;
  35.          invalidate(InvalidationType.STYLES);
  36.       }
  37.       
  38.       override protected function initializeAccessibility() : void
  39.       {
  40.          if(Button.createAccessibilityImplementation != null)
  41.          {
  42.             Button.createAccessibilityImplementation(this);
  43.          }
  44.       }
  45.       
  46.       protected function drawEmphasized() : void
  47.       {
  48.          var _loc2_:Number = NaN;
  49.          if(emphasizedBorder != null)
  50.          {
  51.             removeChild(emphasizedBorder);
  52.          }
  53.          emphasizedBorder = null;
  54.          if(!_emphasized)
  55.          {
  56.             return;
  57.          }
  58.          var _loc1_:Object = getStyleValue("emphasizedSkin");
  59.          if(_loc1_ != null)
  60.          {
  61.             emphasizedBorder = getDisplayObjectInstance(_loc1_);
  62.          }
  63.          if(emphasizedBorder != null)
  64.          {
  65.             addChildAt(emphasizedBorder,0);
  66.             _loc2_ = Number(getStyleValue("emphasizedPadding"));
  67.             emphasizedBorder.x = emphasizedBorder.y = -_loc2_;
  68.             emphasizedBorder.width = width + _loc2_ * 2;
  69.             emphasizedBorder.height = height + _loc2_ * 2;
  70.          }
  71.       }
  72.       
  73.       public function get emphasized() : Boolean
  74.       {
  75.          return _emphasized;
  76.       }
  77.       
  78.       override protected function draw() : void
  79.       {
  80.          if(isInvalid(InvalidationType.STYLES) || isInvalid(InvalidationType.SIZE))
  81.          {
  82.             drawEmphasized();
  83.          }
  84.          super.draw();
  85.          if(emphasizedBorder != null)
  86.          {
  87.             setChildIndex(emphasizedBorder,numChildren - 1);
  88.          }
  89.       }
  90.       
  91.       override public function drawFocus(param1:Boolean) : void
  92.       {
  93.          var _loc2_:Number = NaN;
  94.          var _loc3_:* = undefined;
  95.          super.drawFocus(param1);
  96.          if(param1)
  97.          {
  98.             _loc2_ = Number(getStyleValue("emphasizedPadding"));
  99.             if(_loc2_ < 0 || !_emphasized)
  100.             {
  101.                _loc2_ = 0;
  102.             }
  103.             _loc3_ = getStyleValue("focusRectPadding");
  104.             _loc3_ = _loc3_ == null ? 2 : _loc3_;
  105.             _loc3_ += _loc2_;
  106.             uiFocusRect.x = -_loc3_;
  107.             uiFocusRect.y = -_loc3_;
  108.             uiFocusRect.width = width + _loc3_ * 2;
  109.             uiFocusRect.height = height + _loc3_ * 2;
  110.          }
  111.       }
  112.    }
  113. }
  114.  
  115.