Something's I got off the net and customized for myself...I was searching hard for this on eon the net...
This is for the volume slider,:
bgSound = new Sound(this);
bgSound.attachSound("Main6TranceSongAmp");/*your audio file name. should be in library & set to Export for action script*/
bgSound.start(0, 99);
slider.slideBar._y = -60; // starting position of handle
slider.slideBar.onEnterFrame = function() {
bgSound.setVolume(18-this._y);
};
slider.slideBar.onPress = function() {
startDrag(this, false, this._x, -60, this._x, 18);
};
slider.slideBar.onRelease = slider.slideBar.onReleaseOutside=function () {
stopDrag();
};
This for the MUTE button. create a mute symbol and add code inside the sybol in the first 2 frames:
FIRST FRAME: Have a sound ON icon button
stop();
var globalVolume:Sound = new Sound();
SoundOn.onRelease = function() {
_root.slider.slideBar._y = 18;
globalVolume.setVolume(0);
gotoAndStop(2);
}
SECOND FRAME: Have a sound OFF icon button
var globalVolume:Sound = new Sound();
SoundOff.onRelease = function() {
_root.slider.slideBar._y = -60;
globalVolume.setVolume(100);
gotoAndStop(1);
}
Feel free to ask me any questions/clarifications!
thank you sooo much! after many months of looking for the mute with slider you finally en-light me. Just for the record, if you are working with a flv player, you just need to tell it the following *(assuming you have been working with the gotoandlearn tutorial..):
mute.onRollOver = function ()
{
if (so.getVolume() != 0)
{
this.gotoAndStop("onOver");
}
else
{
this.gotoAndStop("muteOver");
} // end else if
};
mute.onRollOut = function ()
{
if (so.getVolume() != 0)
{
this.gotoAndStop("on");
}
else
{
this.gotoAndStop("mute");
} // end else i
};
mute.onRelease = function ()
{
if (so.getVolume() != 0)
{
_root.slider.slideBar._x = 0;
this.gotoAndStop("muteOver");
}
else
{
_root.slider.slideBar._x = 20;
this.gotoAndStop("onOver");
} // end else if
};the only thing that my solution lack is to know where the slider is at the exact moment of mute, so I told the whole function to do it if the volume ain't 0 (already muted!) and if muted to return to a nice volume (50% since my slideBar is 40px width..)
anyway hope it helps anyone!
I thought I add this useful code to add a mute button in their flash app.
var globalVolume:Sound = new Sound();
muteButton.onRelease = function() {
globalVolume.setVolume((globalVolume.getVolume()+100) % 200);
}