Groups | Blog | Home
all groups > flash actionscript > april 2007 >

flash actionscript : Volume Slider


Amy Berry
4/4/2007 9:28:19 PM

[quoted text, click to view]

If I understand, you start the button in the center, which I assume is 50%
volume?


If you are setting the registration point to the upper left then...
left = _x;
right = _x + _width;

If it is the center then...
left = _x - _width / 2;
right _x + _width / 2;

Then...
var gotoLocation = 100 * (_right - _x ) / _width
this._parent.mySound.setVolume(gotoLocation);

NOTE: Not tested...


soodonimus
4/4/2007 11:31:09 PM
Hello, I have created a volume slider with a button that starts in the center.
When I drag the button left, the volume increases. When I drag right the volume
decreases. How do I change the volume so that dragging left will decrease the
sound and dragging right will increase the sound?

onClipEvent (load) {
top = _y;
bottom = _y;
center = _x;
left = center - 40;
right = center + 40;

}
onClipEvent (enterFrame) {
if (dragging == true) {
this._parent.mySound.setVolume(100-((_x-center)*2.5));
}
}
soodonimus
4/5/2007 3:13:56 PM
Thank you! Yes, I want the button to start in the center at 50% volume. I see
that the variable controls the volume direction. I want the volume to decrease
when I slide left and increase when I slide right, so here is the final code:

onClipEvent (load) {
top = _y;
bottom = _y;
center = _x;
left = center - 40;
right = center + 40;

}
onClipEvent (enterFrame) {
if (dragging == true) {
var gotoLocation = 100*(left-_x)/40;
this._parent.mySound.setVolume(gotoLocation);
}
}
AddThis Social Bookmark Button