Class SoundSlider
**
* vers 1.0
* @author bloba
*
* Requires:
* a MovieClip as registration and in that clip two further clips: on xpos/ypos: 0/0
* base 100 x10 px
* bar 10 x 10 px
*
*
* usage:
*
*
* var mySound:Sound = new Sound();
mySound.loadSound(”my.mp3″,true);
var s:SoundSlider = new SoundSlider (controll_clip , mySound , 100);
*/
class utils.SoundSlider
{
private var loc:MovieClip;
private var drag:MovieClip;
private var base:MovieClip;
private static var maxVal:Number = 100;
private static var minVal:Number = 0;
private var aktVal:Number;
private var soundObj:Sound;
function SoundSlider(_clip:MovieClip,_snd:Sound,_startVolume )
{
aktVal = _startVolume;
this.loc = _clip;
this.soundObj = _snd;
this.run ();
}
private function run():Void
{
trace (“new SoundSlider”);
this.loc.drag._x = aktVal;
if (this.loc.drag._x > 90)
{this.loc.drag._x = 90}
this.loc.drag._y = 0;
this.contolls();
this.calcVals(aktVal);// autostart;)
}
private function contolls ():Void
{
var scope:Object = this;
this.loc.drag.onPress = function()
{
this.startDrag (false, minVal, 0, maxVal - this._width, 0);
scope.startWatcher();
}
this.loc.drag.onRelease = this.loc.drag.onReleaseOutside= function()
{
this.stopDrag();
scope.stopWatcher();
}
this.loc.base.onPress = function ()
{
scope.loc.drag._x = this._xmouse;
scope.calcVals(scope.loc.drag._x);
if (this._xmouse > 90)
{scope.loc.drag._x = 90}
}
}
private function startWatcher():Void
{
var scope:Object = this;
this.loc.drag.onEnterFrame = function()
{
scope.calcVals(this._x);
}
}
private function stopWatcher():Void
{
delete (this.loc.drag.onEnterFrame);
}
private function calcVals (_xpos:Number):Void
{
aktVal = Math.floor(_xpos / .9);
this.soundObj.setVolume(aktVal);
}
}