Groups | Blog | Home
all groups > flash actionscript > august 2006 >

flash actionscript : Sound Volume Knob


Design IQ
8/9/2006 9:39:17 PM
Hello Everyone,

I am building a flash sound player and it uses knobs instead of sliders. I am
having a hard time establishing the volume, and left to right balance. I have
the panning control working left to right but not the sound to turn up and down
working with a dynamically loaded MP3s.

Anyone have an example or source files to make this work?

I will post the code if no one has any examples.

Thanks,
DesignIQ
Design IQ
8/9/2006 10:32:16 PM
Frame Actions

/*
set maximum rotation of the knob.
read initial volume of sound and set corresponding position of knob.
*/
onClipEvent(load){
//maximum angle of rotation for the knob
maxRotAngle = 120;

//read the initial volume & set the position of the knob
this.rotbutton._rotation = (2*_root.s.getVolume() - 100)*maxRotAngle/100;

//read the initial pan and set the position of the knob
//this.rotbutton._rotation = _root.s.getPan() * maxRotAngle/100;
}

/*
set the volume depending on the position of the knob
use forumla to convert _rotation into volume or pan range
*/
onClipEvent(enterFrame){
if (rotbutton.dorotate) {

_root.s.setVolume(Math.floor((100+this.rotbutton._rotation/maxRotAngle*100)/2)
);
//_root.s.setPan(Math.floor((this.rotbutton._rotation/maxRotAngle*100)));
}

//update readouts...
_root.sovolume = _root.s.getVolume();
_root.dialangle = this.rotbutton._rotation;
}

///////////////////////*


MovieClip Actions

/*
set maximum rotation of the knob.
read initial volume of sound and set corresponding position of knob.
*/
onClipEvent(load){
//maximum angle of rotation for the knob
maxRotAngle = 120;

//read the initial volume & set the position of the knob
this.rotbutton._rotation = (2*_root.s.getVolume() - 100)*maxRotAngle/100;

//read the initial pan and set the position of the knob
//this.rotbutton._rotation = _root.s.getPan() * maxRotAngle/100;
}

/*
set the volume depending on the position of the knob
use forumla to convert _rotation into volume or pan range
*/
onClipEvent(enterFrame){
if (rotbutton.dorotate) {

_root.s.setVolume(Math.floor((100+this.rotbutton._rotation/maxRotAngle*100)/2)
);
//_root.s.setPan(Math.floor((this.rotbutton._rotation/maxRotAngle*100)));
}

//update readouts...
_root.sovolume = _root.s.getVolume();
_root.dialangle = this.rotbutton._rotation;
}

///////////////////////*


Help.

AddThis Social Bookmark Button