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 / TSRadioButtonGroup.as < prev    next >
Encoding:
Text File  |  2010-09-09  |  3.3 KB  |  134 lines

  1. class com.techsmith.widgets.button.TSRadioButtonGroup implements com.techsmith.utils.events.IEventDispatcher
  2. {
  3.    var m_dispatcher = null;
  4.    var m_radioGroup = null;
  5.    var m_selected = null;
  6.    function TSRadioButtonGroup()
  7.    {
  8.       this.m_dispatcher = new com.techsmith.utils.events.EventDispatcher();
  9.       this.m_radioGroup = new Array();
  10.    }
  11.    function addRadioButton(button)
  12.    {
  13.       var _loc4_ = this.m_radioGroup.length;
  14.       var _loc2_ = 0;
  15.       while(_loc2_ < _loc4_)
  16.       {
  17.          if(button == this.m_radioGroup[_loc2_])
  18.          {
  19.             return undefined;
  20.          }
  21.          _loc2_ = _loc2_ + 1;
  22.       }
  23.       this.m_radioGroup.push(button);
  24.       button.addEventListener("click",this);
  25.    }
  26.    function removeRadioButton(button)
  27.    {
  28.       var _loc4_ = this.m_radioGroup.length;
  29.       var _loc2_ = 0;
  30.       while(_loc2_ < _loc4_)
  31.       {
  32.          if(button == this.m_radioGroup[_loc2_])
  33.          {
  34.             this.m_radioGroup.splice(_loc2_,1);
  35.             button.removeEventListener("click",this);
  36.          }
  37.          _loc2_ = _loc2_ + 1;
  38.       }
  39.    }
  40.    function onUnload()
  41.    {
  42.       var _loc3_ = this.m_radioGroup.length;
  43.       var _loc2_ = 0;
  44.       while(_loc2_ < _loc3_)
  45.       {
  46.          this.m_radioGroup[_loc2_].removeEventListener("click",this);
  47.          _loc2_ = _loc2_ + 1;
  48.       }
  49.       this.m_dispatcher.removeAllListeners();
  50.    }
  51.    function enforceSelectionRules(e)
  52.    {
  53.       var _loc3_ = this.m_radioGroup.length;
  54.       var _loc2_ = 0;
  55.       while(_loc2_ < _loc3_)
  56.       {
  57.          if(this.m_radioGroup[_loc2_] != e)
  58.          {
  59.             this.m_radioGroup[_loc2_].setSelected(false);
  60.          }
  61.          else
  62.          {
  63.             this.m_selected = this.m_radioGroup[_loc2_];
  64.          }
  65.          _loc2_ = _loc2_ + 1;
  66.       }
  67.    }
  68.    function setSelected(button)
  69.    {
  70.       this.m_selected = button;
  71.       button.setSelected(true);
  72.       this.enforceSelectionRules(button);
  73.    }
  74.    function setEnabled(enabled)
  75.    {
  76.       var _loc3_ = this.m_radioGroup.length;
  77.       var _loc2_ = 0;
  78.       while(_loc2_ < _loc3_)
  79.       {
  80.          this.m_radioGroup[_loc2_].setEnabled(enabled);
  81.          _loc2_ = _loc2_ + 1;
  82.       }
  83.    }
  84.    function getSelected()
  85.    {
  86.       return this.m_selected;
  87.    }
  88.    function getSelectedName()
  89.    {
  90.       return this.m_selected._name;
  91.    }
  92.    function getValue()
  93.    {
  94.       return this.m_selected.getValue();
  95.    }
  96.    function getLabel()
  97.    {
  98.       return this.m_selected.getLabel();
  99.    }
  100.    function getData()
  101.    {
  102.       return this.m_selected.getData();
  103.    }
  104.    function setData(data)
  105.    {
  106.       if(this.m_selected != null || this.m_selected != undefined)
  107.       {
  108.          this.m_selected.setData(data);
  109.          return true;
  110.       }
  111.       return false;
  112.    }
  113.    function click(e)
  114.    {
  115.       this.dispatchEvent({target:this,type:"click",button:e.target});
  116.    }
  117.    function sendEvent(e)
  118.    {
  119.       this.dispatchEvent(e);
  120.    }
  121.    function addEventListener(event, scope)
  122.    {
  123.       this.m_dispatcher.addEventListener(event,scope);
  124.    }
  125.    function removeEventListener(event, scope)
  126.    {
  127.       this.m_dispatcher.removeEventListener(event,scope);
  128.    }
  129.    function dispatchEvent(eventObj)
  130.    {
  131.       this.m_dispatcher.dispatchEvent(eventObj);
  132.    }
  133. }
  134.