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 / CheckBox.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  4.2 KB  |  127 lines

  1. package fl.controls
  2. {
  3.    import flash.display.DisplayObject;
  4.    import flash.display.Graphics;
  5.    import flash.display.Shape;
  6.    
  7.    [Embed(source="/_assets/assets.swf", symbol="symbol30")]
  8.    public class CheckBox extends LabelButton
  9.    {
  10.       public static var createAccessibilityImplementation:Function;
  11.       
  12.       private static var defaultStyles:Object = {
  13.          "icon":null,
  14.          "upIcon":"CheckBox_upIcon",
  15.          "downIcon":"CheckBox_downIcon",
  16.          "overIcon":"CheckBox_overIcon",
  17.          "disabledIcon":"CheckBox_disabledIcon",
  18.          "selectedDisabledIcon":"CheckBox_selectedDisabledIcon",
  19.          "focusRectSkin":null,
  20.          "focusRectPadding":null,
  21.          "selectedUpIcon":"CheckBox_selectedUpIcon",
  22.          "selectedDownIcon":"CheckBox_selectedDownIcon",
  23.          "selectedOverIcon":"CheckBox_selectedOverIcon",
  24.          "textFormat":null,
  25.          "disabledTextFormat":null,
  26.          "embedFonts":null,
  27.          "textPadding":5
  28.       };
  29.       
  30.       public function CheckBox()
  31.       {
  32.          super();
  33.       }
  34.       
  35.       public static function getStyleDefinition() : Object
  36.       {
  37.          return defaultStyles;
  38.       }
  39.       
  40.       override protected function drawBackground() : void
  41.       {
  42.       }
  43.       
  44.       override public function get toggle() : Boolean
  45.       {
  46.          return true;
  47.       }
  48.       
  49.       override protected function initializeAccessibility() : void
  50.       {
  51.          if(CheckBox.createAccessibilityImplementation != null)
  52.          {
  53.             CheckBox.createAccessibilityImplementation(this);
  54.          }
  55.       }
  56.       
  57.       override public function set toggle(param1:Boolean) : void
  58.       {
  59.          throw new Error("Warning: You cannot change a CheckBox\'s toggle.");
  60.       }
  61.       
  62.       override public function get autoRepeat() : Boolean
  63.       {
  64.          return false;
  65.       }
  66.       
  67.       override public function set autoRepeat(param1:Boolean) : void
  68.       {
  69.       }
  70.       
  71.       override public function drawFocus(param1:Boolean) : void
  72.       {
  73.          var _loc2_:Number = NaN;
  74.          super.drawFocus(param1);
  75.          if(param1)
  76.          {
  77.             _loc2_ = Number(getStyleValue("focusRectPadding"));
  78.             uiFocusRect.x = background.x - _loc2_;
  79.             uiFocusRect.y = background.y - _loc2_;
  80.             uiFocusRect.width = background.width + (_loc2_ << 1);
  81.             uiFocusRect.height = background.height + (_loc2_ << 1);
  82.          }
  83.       }
  84.       
  85.       override protected function configUI() : void
  86.       {
  87.          super.configUI();
  88.          super.toggle = true;
  89.          var _loc1_:Shape = new Shape();
  90.          var _loc2_:Graphics = _loc1_.graphics;
  91.          _loc2_.beginFill(0,0);
  92.          _loc2_.drawRect(0,0,100,100);
  93.          _loc2_.endFill();
  94.          background = _loc1_ as DisplayObject;
  95.          addChildAt(background,0);
  96.       }
  97.       
  98.       override protected function drawLayout() : void
  99.       {
  100.          super.drawLayout();
  101.          var _loc1_:Number = Number(getStyleValue("textPadding"));
  102.          switch(_labelPlacement)
  103.          {
  104.             case ButtonLabelPlacement.RIGHT:
  105.                icon.x = _loc1_;
  106.                textField.x = icon.x + (icon.width + _loc1_);
  107.                background.width = textField.x + textField.width + _loc1_;
  108.                background.height = Math.max(textField.height,icon.height) + _loc1_ * 2;
  109.                break;
  110.             case ButtonLabelPlacement.LEFT:
  111.                icon.x = width - icon.width - _loc1_;
  112.                textField.x = width - icon.width - _loc1_ * 2 - textField.width;
  113.                background.width = textField.width + icon.width + _loc1_ * 3;
  114.                background.height = Math.max(textField.height,icon.height) + _loc1_ * 2;
  115.                break;
  116.             case ButtonLabelPlacement.TOP:
  117.             case ButtonLabelPlacement.BOTTOM:
  118.                background.width = Math.max(textField.width,icon.width) + _loc1_ * 2;
  119.                background.height = textField.height + icon.height + _loc1_ * 3;
  120.          }
  121.          background.x = Math.min(icon.x - _loc1_,textField.x - _loc1_);
  122.          background.y = Math.min(icon.y - _loc1_,textField.y - _loc1_);
  123.       }
  124.    }
  125. }
  126.  
  127.