home *** CD-ROM | disk | FTP | other *** search
/ The Complete Idiot's Guide to Microsoft Excel 2010 / CIGExcel.iso / Videos / Flash / controller.swf / scripts / __Packages / com / techsmith / widgets / button / TSButton.as next >
Encoding:
Text File  |  2010-09-09  |  3.8 KB  |  135 lines

  1. class com.techsmith.widgets.button.TSButton extends com.techsmith.widgets.button.TSSimpleButton
  2. {
  3.    var m_label = null;
  4.    var m_labelField = null;
  5.    var m_labelFormat = null;
  6.    var m_width = null;
  7.    var m_height = 27;
  8.    var m_graphic = null;
  9.    var m_disabledColor = 13555676;
  10.    var m_enabledColor = 0;
  11.    function TSButton()
  12.    {
  13.       super();
  14.    }
  15.    static function create(container, name, depth, init)
  16.    {
  17.       com.techsmith.widgets.button.TSButton.bind();
  18.       var _loc1_ = container.attachMovie("TSButton",name,depth,init);
  19.       return com.techsmith.widgets.button.TSButton(_loc1_);
  20.    }
  21.    static function bind()
  22.    {
  23.       Object.registerClass("TSButtonUp",com.techsmith.widgets.button.panels.TSButtonUp);
  24.       Object.registerClass("TSButtonOver",com.techsmith.widgets.button.panels.TSButtonOver);
  25.       Object.registerClass("TSButtonDown",com.techsmith.widgets.button.panels.TSButtonDown);
  26.       Object.registerClass("TSButtonDisabled",com.techsmith.widgets.button.panels.TSButtonDisabled);
  27.    }
  28.    function init(label, width, toggle, tf, bs)
  29.    {
  30.       if(label == null || label == undefined)
  31.       {
  32.          label = "";
  33.       }
  34.       if(width == null || width == undefined)
  35.       {
  36.          width = 100;
  37.       }
  38.       if(toggle == null || toggle == undefined)
  39.       {
  40.          toggle = false;
  41.       }
  42.       if(bs == null || bs == undefined)
  43.       {
  44.          bs = new com.techsmith.widgets.button.TSButtonStyle("TSButton",null,toggle);
  45.       }
  46.       this.m_label = label;
  47.       this.m_width = width;
  48.       super.init(bs);
  49.       this.m_graphic.init(this.m_width);
  50.       this.createLabelField();
  51.       this.createTextFormat(tf);
  52.       this.setLabel(this.m_label);
  53.    }
  54.    function createLabelField()
  55.    {
  56.       this.createTextField("m_labelField",10,0,0,this.m_width,this.m_height - 5);
  57.       this.m_labelField._y = (this.m_height - this.m_labelField._height) / 2 + 2;
  58.       this.m_labelField.html = true;
  59.    }
  60.    function createTextFormat(obj)
  61.    {
  62.       if(obj == null || obj == undefined)
  63.       {
  64.          this.m_labelFormat = new TextFormat();
  65.          this.m_labelFormat.align = "center";
  66.          this.m_labelFormat.font = "Arial";
  67.          this.m_labelFormat.size = 12;
  68.          this.m_labelFormat.leftMargin = 2;
  69.          this.m_labelFormat.rightMargin = 2;
  70.          this.m_labelFormat.color = 0;
  71.       }
  72.       else
  73.       {
  74.          this.m_labelFormat = obj;
  75.       }
  76.       this.m_enabledColor = this.m_labelFormat.color;
  77.    }
  78.    function draw()
  79.    {
  80.       this.createLabelField();
  81.       this.m_graphic.setSize(this.m_width,this.m_height);
  82.       this.setLabel(this.m_label);
  83.    }
  84.    function setSize(width, height)
  85.    {
  86.       this.m_width = width;
  87.       this.draw();
  88.    }
  89.    function setLabel(label)
  90.    {
  91.       this.m_label = label;
  92.       this.m_labelField.htmlText = this.m_label;
  93.       this.m_labelField.setTextFormat(this.m_labelFormat);
  94.    }
  95.    function setEnabled(enable)
  96.    {
  97.       super.setEnabled(enable);
  98.       this.m_graphic.init(this.m_width);
  99.       if(enable)
  100.       {
  101.          this.m_labelFormat.color = this.m_enabledColor;
  102.       }
  103.       else
  104.       {
  105.          this.m_labelFormat.color = this.m_disabledColor;
  106.       }
  107.       this.setLabel(this.m_label);
  108.    }
  109.    function onRollOver()
  110.    {
  111.       super.onRollOver();
  112.       this.m_graphic.init(this.m_width);
  113.    }
  114.    function onRollOut()
  115.    {
  116.       super.onRollOut();
  117.       this.m_graphic.init(this.m_width);
  118.    }
  119.    function onPress()
  120.    {
  121.       super.onPress();
  122.       this.m_graphic.init(this.m_width);
  123.    }
  124.    function onRelease()
  125.    {
  126.       super.onRelease();
  127.       this.m_graphic.init(this.m_width);
  128.    }
  129.    function onReleaseOutside()
  130.    {
  131.       super.onReleaseOutside();
  132.       this.m_graphic.init(this.m_width);
  133.    }
  134. }
  135.