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.
many
julie
*
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);
}
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
Post a Comment