Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 598
  • Last Modified:

making a button to change the global volume

Im making a cd rom with voice over prompts for stage elements. Id like the user to able to turn off the prompts if they so choose. Unfortunatly stopallsounds works for continuous audio so I think I need a solution that checks the current global volume and turns it to the oposite. ie, if the volume is on (100) the button then turns it to off (0) and vice versa. In this way the user can turn sound on and off.
Any help will be gratefully received.
0
sousflai
Asked:
sousflai
  • 2
  • 2
1 Solution
 
DavidTMooreCommented:
(note this is AS2, please let me know if you need AS3 code)

Put this in the first frame of the main timeline, this should create a global sound variable.

var globalSound:Sound = new Sound();
globalSound.setVolume(100);


then on your button click event handler use the following code.

if(_root.globalSound.getVolume() == 100)
{
      _root.globalSound.setVolume(0);      
}
else
{
      _root.globalSound.setVolume(100);
}


cheers
~David
0
 
sousflaiAuthor Commented:
your a genius!
0
 
DavidTMooreCommented:
glad to help.

cheers
~David
0
 
sousflaiAuthor Commented:
I dont suppose you know how to get a button create an empty movie clip then import a jpg file from the library inside the clip. Also importing a button that will automatically remove the movie clip when pressed?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now