sound volume


hi porting lingo flash , need simple solution problem. have 2 movieclps on stage , wish 1 function "up" volume control , other work "down" control. incrementally. i've written code. can "up" control work fine, "down" volume won't work. ideas or tutorials gratefully received.

quote:


//variable set 0
up_vol = 0;


sound_up_mc.onpress = function() {

//on mouse press increment value of vol 10
up_vol = up_vol + 10

//set volume value of sound value contained in vol.
my_sound.setvolume(up_vol);


}

//set variable down volume.

down_vol = 0

sound_down_mc.onpress = function() {

//plug down_vol value setvolume parameter

down_vol = down_vol - 10
my_sound.setvolume(down_vol);

}




many

julie
*

well, make more sense have 1 volume variable. button increase value, whilst down button decrease it. also, instead of using code "x = x+10", can use 'addition assignment operator' same thing: x+=10. said, have like:


vol = 0;
sound_up_mc.onpress = function() {
vol+=10;
my_sound.setvolume(vol);
}

sound_down_mc.onpress = function() {
vol-=10;
my_sound.setvolume(vol);
}

but let's consider when hit down volume button when volume @ 0, become negative. same idea applies volume button when volume reaches 100, except exceed maximum volume. handle that, can use if statement, bring volume within proper range:

//initial volume
vol = 0;
my_sound.setvolume(vol);
//increse volume button
sound_up_mc.onpress = function() {
vol+=10;
if(vol > 100){
vol = 100;
}
my_sound.setvolume(vol);
}
//decrease volume button
sound_down_mc.onpress = function() {
vol-=10;
if(vol < 0){
vol = 0;
}
my_sound.setvolume(vol);
}


More discussions in ActionScript 1 and 2


adobe

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial