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 / TSSimpleButton.as < prev   
Encoding:
Text File  |  2010-09-09  |  5.3 KB  |  182 lines

  1. class com.techsmith.widgets.button.TSSimpleButton extends com.techsmith.widgets.Movable implements com.techsmith.utils.events.IEventDispatcher
  2. {
  3.    var m_dispatcher = null;
  4.    var m_fToggleState = null;
  5.    var m_styleObj = null;
  6.    var m_graphic = null;
  7.    var m_toggle = null;
  8.    var m_fGraphicY = 0;
  9.    var m_fGraphicX = 0;
  10.    var m_mouseState = null;
  11.    function TSSimpleButton()
  12.    {
  13.       super();
  14.       this.useHandCursor = false;
  15.       this.m_dispatcher = new com.techsmith.utils.events.EventDispatcher();
  16.       this.m_fToggleState = true;
  17.       this.m_toggle = false;
  18.    }
  19.    static function create(container, name, depth, init)
  20.    {
  21.       var _loc1_ = container.attachMovie("TSSimpleButton",name,depth,init);
  22.       return com.techsmith.widgets.button.TSSimpleButton(_loc1_);
  23.    }
  24.    function init(styleObj)
  25.    {
  26.       this.m_styleObj = styleObj;
  27.       this.m_toggle = styleObj.m_toggle;
  28.       if(!this.m_toggle)
  29.       {
  30.          this.m_graphic = this.attachMovie(this.m_styleObj.m_trueUpSkin,"m_graphic",5);
  31.       }
  32.       else if(this.m_fToggleState)
  33.       {
  34.          this.m_graphic = this.attachMovie(this.m_styleObj.m_trueUpSkin,"m_graphic",5);
  35.       }
  36.       else
  37.       {
  38.          this.m_graphic = this.attachMovie(this.m_styleObj.m_falseUpSkin,"m_graphic",5);
  39.       }
  40.       this.positionIcon();
  41.    }
  42.    function positionIcon()
  43.    {
  44.       this.m_graphic._x = this.m_fGraphicX;
  45.       this.m_graphic._y = this.m_fGraphicY;
  46.    }
  47.    function onRollOver()
  48.    {
  49.       if(!this.m_toggle)
  50.       {
  51.          this.m_graphic = this.attachMovie(this.m_styleObj.m_trueOverSkin,"m_graphic",5);
  52.       }
  53.       else if(this.m_fToggleState)
  54.       {
  55.          this.m_graphic = this.attachMovie(this.m_styleObj.m_trueOverSkin,"m_graphic",5);
  56.       }
  57.       else
  58.       {
  59.          this.m_graphic = this.attachMovie(this.m_styleObj.m_falseOverSkin,"m_graphic",5);
  60.       }
  61.       this.positionIcon();
  62.    }
  63.    function onPress()
  64.    {
  65.       if(!this.m_toggle)
  66.       {
  67.          this.m_graphic = this.attachMovie(this.m_styleObj.m_trueDownSkin,"m_graphic",5);
  68.       }
  69.       else if(this.m_fToggleState)
  70.       {
  71.          this.m_graphic = this.attachMovie(this.m_styleObj.m_trueDownSkin,"m_graphic",5);
  72.       }
  73.       else
  74.       {
  75.          this.m_graphic = this.attachMovie(this.m_styleObj.m_falseDownSkin,"m_graphic",5);
  76.       }
  77.       this.positionIcon();
  78.    }
  79.    function onRelease()
  80.    {
  81.       this.m_fToggleState = !this.m_fToggleState ? true : false;
  82.       if(!this.m_toggle)
  83.       {
  84.          this.m_graphic = this.attachMovie(this.m_styleObj.m_trueOverSkin,"m_graphic",5);
  85.       }
  86.       else if(this.m_fToggleState)
  87.       {
  88.          this.m_graphic = this.attachMovie(this.m_styleObj.m_trueOverSkin,"m_graphic",5);
  89.       }
  90.       else
  91.       {
  92.          this.m_graphic = this.attachMovie(this.m_styleObj.m_falseOverSkin,"m_graphic",5);
  93.       }
  94.       this.positionIcon();
  95.       this.sendEvent({target:this,type:"click"});
  96.    }
  97.    function onReleaseOutside()
  98.    {
  99.       this.m_fToggleState = !this.m_fToggleState ? true : false;
  100.       if(!this.m_toggle)
  101.       {
  102.          this.m_graphic = this.attachMovie(this.m_styleObj.m_trueUpSkin,"m_graphic",5);
  103.       }
  104.       else if(this.m_fToggleState)
  105.       {
  106.          this.m_graphic = this.attachMovie(this.m_styleObj.m_trueUpSkin,"m_graphic",5);
  107.       }
  108.       else
  109.       {
  110.          this.m_graphic = this.attachMovie(this.m_styleObj.m_falseUpSkin,"m_graphic",5);
  111.       }
  112.       this.positionIcon();
  113.    }
  114.    function onRollOut()
  115.    {
  116.       if(!this.m_toggle)
  117.       {
  118.          this.m_graphic = this.attachMovie(this.m_styleObj.m_trueUpSkin,"m_graphic",5);
  119.       }
  120.       else if(this.m_fToggleState)
  121.       {
  122.          this.m_graphic = this.attachMovie(this.m_styleObj.m_trueUpSkin,"m_graphic",5);
  123.       }
  124.       else
  125.       {
  126.          this.m_graphic = this.attachMovie(this.m_styleObj.m_falseUpSkin,"m_graphic",5);
  127.       }
  128.       this.positionIcon();
  129.    }
  130.    function setEnabled(enable)
  131.    {
  132.       this.enabled = enable;
  133.       if(!enable)
  134.       {
  135.          if(!this.m_toggle)
  136.          {
  137.             this.m_graphic = this.attachMovie(this.m_styleObj.m_trueDisabledSkin,"m_graphic",5);
  138.          }
  139.          else if(this.m_fToggleState)
  140.          {
  141.             this.m_graphic = this.attachMovie(this.m_styleObj.m_trueDisabledSkin,"m_graphic",5);
  142.          }
  143.          else
  144.          {
  145.             this.m_graphic = this.attachMovie(this.m_styleObj.m_falseDisabledSkin,"m_graphic",5);
  146.          }
  147.       }
  148.       else if(enable)
  149.       {
  150.          if(!this.m_toggle)
  151.          {
  152.             this.m_graphic = this.attachMovie(this.m_styleObj.m_trueUpSkin,"m_graphic",5);
  153.          }
  154.          else if(this.m_fToggleState)
  155.          {
  156.             this.m_graphic = this.attachMovie(this.m_styleObj.m_trueUpSkin,"m_graphic",5);
  157.          }
  158.          else
  159.          {
  160.             this.m_graphic = this.attachMovie(this.m_styleObj.m_falseUpSkin,"m_graphic",5);
  161.          }
  162.       }
  163.       this.positionIcon();
  164.    }
  165.    function sendEvent(e)
  166.    {
  167.       this.dispatchEvent(e);
  168.    }
  169.    function addEventListener(event, scope)
  170.    {
  171.       this.m_dispatcher.addEventListener(event,scope);
  172.    }
  173.    function removeEventListener(event, scope)
  174.    {
  175.       this.m_dispatcher.removeEventListener(event,scope);
  176.    }
  177.    function dispatchEvent(eventObj)
  178.    {
  179.       this.m_dispatcher.dispatchEvent(eventObj);
  180.    }
  181. }
  182.