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

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