home *** CD-ROM | disk | FTP | other *** search
/ i·claim - visualizing argument / ICLAIM.ISO / mac / glossary.swf / scripts / __Packages / mx / controls / streamingmedia / VolumeControlHandle.as < prev    next >
Text File  |  2005-02-24  |  2KB  |  106 lines

  1. class mx.controls.streamingmedia.VolumeControlHandle extends MovieClip
  2. {
  3.    function VolumeControlHandle()
  4.    {
  5.       super();
  6.       this.init();
  7.    }
  8.    function init()
  9.    {
  10.       this._volumeControl = this._parent;
  11.       this._controller = this._parent._parent;
  12.       this.setVolume(this._controller.__get__volume());
  13.       this.__set__enabled(this._controller.enabled);
  14.       this.tabEnabled = false;
  15.       this.tabChildren = false;
  16.    }
  17.    function isVertical()
  18.    {
  19.       return !this._controller.__get__horizontal();
  20.    }
  21.    function setVolume(aVolume)
  22.    {
  23.       if(aVolume < 0)
  24.       {
  25.          aVolume = 0;
  26.       }
  27.       else if(aVolume > 100)
  28.       {
  29.          aVolume = 100;
  30.       }
  31.       this._x = this.volumeToX(aVolume);
  32.    }
  33.    function setMute()
  34.    {
  35.       this.setVolume(0);
  36.    }
  37.    function setLoud()
  38.    {
  39.       this.setVolume(100);
  40.    }
  41.    function handlePress()
  42.    {
  43.       this.startThumbDrag();
  44.    }
  45.    function handleRelease()
  46.    {
  47.       this.stopThumbDrag();
  48.    }
  49.    function handleReleaseOutside()
  50.    {
  51.       this.stopThumbDrag();
  52.    }
  53.    function startThumbDrag()
  54.    {
  55.       this.startDrag(false,12,3,12 + this.getRange(),3);
  56.       this.onMouseMove = this.handleMouseMove;
  57.    }
  58.    function stopThumbDrag()
  59.    {
  60.       this.stopDrag();
  61.       delete this.onMouseMove;
  62.       this.broadcastEvent();
  63.    }
  64.    function handleMouseMove()
  65.    {
  66.       this.broadcastEvent();
  67.    }
  68.    function broadcastEvent()
  69.    {
  70.       this._controller.broadcastEvent("volume",this.xToVolume(this._x));
  71.    }
  72.    function xToVolume(x)
  73.    {
  74.       return (x - 12) * (100 / this.getRange());
  75.    }
  76.    function volumeToX(aVol)
  77.    {
  78.       return aVol / (100 / this.getRange()) + 12;
  79.    }
  80.    function getRange()
  81.    {
  82.       var _loc2_ = !this.isVertical() ? 50 : 27;
  83.       return _loc2_;
  84.    }
  85.    function get enabled()
  86.    {
  87.       return this._enabled;
  88.    }
  89.    function set enabled(is)
  90.    {
  91.       this._enabled = is;
  92.       if(is)
  93.       {
  94.          this.onPress = this.handlePress;
  95.          this.onRelease = this.handleRelease;
  96.          this.onReleaseOutside = this.handleReleaseOutside;
  97.       }
  98.       else
  99.       {
  100.          delete this.onPress;
  101.          delete this.onRelease;
  102.          delete this.onReleaseOutside;
  103.       }
  104.    }
  105. }
  106.