home *** CD-ROM | disk | FTP | other *** search
- class mx.controls.streamingmedia.VolumeControlHandle extends MovieClip
- {
- var _volumeControl;
- var _controller;
- var onMouseMove;
- var _enabled;
- var onPress;
- var onRelease;
- var onReleaseOutside;
- function VolumeControlHandle()
- {
- super();
- this.init();
- }
- function init()
- {
- this._volumeControl = this._parent;
- this._controller = this._parent._parent;
- this.setVolume(this._controller.volume);
- this.enabled = this._controller.enabled;
- this.tabEnabled = false;
- this.tabChildren = false;
- }
- function isVertical()
- {
- return !this._controller.horizontal;
- }
- function setVolume(aVolume)
- {
- if(aVolume < 0)
- {
- aVolume = 0;
- }
- else if(aVolume > 100)
- {
- aVolume = 100;
- }
- this._x = this.volumeToX(aVolume);
- }
- function setMute()
- {
- this.setVolume(0);
- }
- function setLoud()
- {
- this.setVolume(100);
- }
- function handlePress()
- {
- this.startThumbDrag();
- }
- function handleRelease()
- {
- this.stopThumbDrag();
- }
- function handleReleaseOutside()
- {
- this.stopThumbDrag();
- }
- function startThumbDrag()
- {
- this.startDrag(false,12,3,12 + this.getRange(),3);
- this.onMouseMove = this.handleMouseMove;
- }
- function stopThumbDrag()
- {
- this.stopDrag();
- delete this.onMouseMove;
- this.broadcastEvent();
- }
- function handleMouseMove()
- {
- this.broadcastEvent();
- }
- function broadcastEvent()
- {
- this._controller.broadcastEvent("volume",this.xToVolume(this._x));
- }
- function xToVolume(x)
- {
- return (x - 12) * (100 / this.getRange());
- }
- function volumeToX(aVol)
- {
- return aVol / (100 / this.getRange()) + 12;
- }
- function getRange()
- {
- var _loc2_ = !this.isVertical() ? 50 : 27;
- return _loc2_;
- }
- function get enabled()
- {
- return this._enabled;
- }
- function set enabled(is)
- {
- this._enabled = is;
- if(is)
- {
- this.onPress = this.handlePress;
- this.onRelease = this.handleRelease;
- this.onReleaseOutside = this.handleReleaseOutside;
- }
- else
- {
- delete this.onPress;
- delete this.onRelease;
- delete this.onReleaseOutside;
- }
- }
- }
-