7 Replies Latest reply on Jul 12, 2006 12:37 AM by kglad

    Mute button

    deltaek
      Using a button to mute sound, I have inserted this code:

      ------------------------------------------------------------------------------------------ ----------------------------
      on (release) {
      tellTarget ("mymusic") {
      volume (0);
      }
      }
      ------------------------------------------------------------------------------------------ ----------------------------

      It doesn't work and I don't know how to fix it. Any ideas? I don't want the sound to stop but rather to stay in sync with the movie and just be muted.

      on (release) {
      tellTarget ("mymusic") {
      play ();
      }
      }

      Works for my play button.

      Thanks,

      Elaine
        • 1. Re: Mute button
          kglad Adobe Community Professional & MVP
          try:

          • 2. Re: Mute button
            deltaek Level 1
            What is this replacing? I tried several options and none worked. As you can tell, I'm new to this.

            Thanks!
            • 3. Re: Mute button
              NSurveyor Level 2
              Well you haven't given much to work with. For instance, what is mymusic? Is it a MovieClip or an instance of the Sound class? If the latter, you would use the line kglad specified in your mute button, and in the unmute button: mymusic.setVolume(100);

              However, if this is a MovieClip, it won't work. You can create an instance of the Sound class to control the MovieClip's volume. Read this to learn how to make a good mute button: http://www.quip.net/blog/2006/flash/how-to-toggle-sound-globally

              (by the way, tellTarget is really old; use dot notation and possibly with(...){...})
              • 4. Re: Mute button
                deltaek Level 1
                It is a movie clip that runs in sync with actions (1800 frames in all). I read the article to the link and it still doesn't help me. All it did was confuse me more...

                I inserted a new layer in my flash file, added the action script var globalVolume:Sound = new Sound(); to frame 1 in this layer.

                I selected my play button and added the script:

                btnSoundOn.onRelease = function() {
                globalVolume.setVolume(100);
                }

                it returns an error of
                ----------------------------------------------
                **Error** Scene=Escena 1, layer=BUTTON, frame=1:Line 1: Statement must appear within on handler
                btnSoundOn.onRelease = function() {

                Total ActionScript Errors: 1 Reported Errors: 1
                ----------------------------------------------

                I haven't even got to the mute part. Can you tell me where I am going wrong?

                Elaine
                • 5. Re: Mute button
                  kglad Adobe Community Professional & MVP
                  your onRelease code should be attached to a frame, not to the button.

                  p.s. you'll need some code to attach or load a sound file into your sound object, globalVolume.
                  • 6. Re: Mute button
                    NSurveyor Level 2
                    Kglad, I thought that this method works whether you have timeline sounds or sounds with the Sound class... as it controls the "global sound" because no target was specified in the constructor.

                    Yeah, so the onRelease goes on the frame, and you should give your button the instance name, btnSoundOn.
                    • 7. Re: Mute button
                      kglad Adobe Community Professional & MVP
                      setVolume() is sound object method. it won't work for a timeline/movieclip sound.