[RESOLVED] [CS3][AS2] Mute Button for Sound Effects
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] [CS3][AS2] Mute Button for Sound Effects

  1. #1
    Junior Member
    Join Date
    Jan 2009
    Posts
    22

    resolved [RESOLVED] [CS3][AS2] Mute Button for Sound Effects

    Alright so I'm making a mute button at the bottom of my game, and with most of the tutorials the button only mutes the sound that is already going on. It doesn't ever mute future sounds that appear in the actionscript. Is there a way to totally mute all the sounds even ones that appear after you click the button?

    Also, what is the best coding for putting in sound effects in a game with using a mute button?

    Edit: Maybe if I create a function for each sound effect and have an if statement in that function saying that it can only play if the mute button is not active?

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    Yes, use one function with sound name passed as parameter to play all sounds. Inside that function check for mute button.

  3. #3
    Junior Member
    Join Date
    Jan 2009
    Posts
    22
    Alright I get all that stuff but I can't seem to get the coding right for the actual button... I want it show the first frame when it isn't muted, and then when it is muted, to show the 2nd frame.

    All in all, when I want it so I can click the button it will be muted on frame 2, and when you click it again, all the sound comes back and it's on frame 1.

    I know it is some sort of else statement...

  4. #4
    Senior Member
    Join Date
    Sep 2004
    Posts
    633
    the simplest way is to create a movie clip with 2 frames. place sound off button on frame 1 and sound on button on frame 2.

    on timeline frame #1 actionscript : sound = new Sound(); ( and of course stop(); so it stops at frame 1 )

    then sound off button code:

    on (release) {
    sound.setVolume(0);
    gotoAndStop(2);
    }

    and sound on button code:

    on (release) {
    sound.setVolume(99);
    gotoAndStop(1);
    }

    That way you don't need to take care of each sound individually, as long as you do not assign a movie clip to this code: sound = new Sound();
    it will control global volume.
    Last edited by MikeMD; 01-21-2009 at 08:18 PM.

  5. #5
    Junior Member
    Join Date
    Jan 2009
    Posts
    22

    Talking Mute Button with AS2

    Quote Originally Posted by MikeMD
    the simplest way is to create a movie clip with 2 frames. place sound off button on frame 1 and sound on button on frame 2.

    on timeline frame #1 actionscript : sound = new Sound(); ( and of course stop(); so it stops at frame 1 )

    then sound off button code:

    on (release) {
    sound.setVolume(0);
    gotoAndStop(2);
    }

    and sound on button code:

    on (release) {
    sound.setVolume(99);
    gotoAndStop(1);
    }

    That way you don't need to take care of each sound individually, as long as you do not assign a movie clip to this code: sound = new Sound();
    it will control global volume.

    Wow it actually worked! Thank you very much.
    Last edited by Werty 2334; 01-22-2009 at 05:37 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com