2 Replies Latest reply on Feb 13, 2008 7:02 AM by 3-Putt

    sound question

    3-Putt Level 1
      My banner has this code which turns off the sound when clicking on a speaker icon...and turns it on clicking the same button.

      var volumeOn:Boolean = true;
      var globalVolume:Sound = new Sound();

      action2.stop();
      action2.toggled = false;

      action2.onRelease = function():Void {
      this.toggled = !this.toggled;
      if (this.toggled) {
      this.gotoAndStop(2);
      (volumeOn)
      globalVolume.setVolume(0)
      } else {
      this.gotoAndStop(1);
      globalVolume.setVolume(100);
      }
      volumeOn = !volumeOn;
      }

      My question is how can I have my banner start with the sound off and have the user turn it on with the speaker icon?

      Can I just modify the existing code? I tried without success.
      Am i doing anything wrong?

      Thanks Brian
        • 1. Re: sound question
          .:}x-=V!P=-x{:. Level 3
          just put

          action2.onRelease();

          at the end of your code on a new line!
          • 2. Re: sound question
            3-Putt Level 1
            Thanks for the info...Ill try it.

            What I did was this...I set the volume to mute and swapped out the volume levels from 0 to 100 in the action2 button.

            var mute:Sound = new Sound();
            mute.setVolume(0)

            var sound2:Sound = new Sound();
            sound2.attachSound("touchdown");

            var volumeOn:Boolean = true;
            var globalVolume:Sound = new Sound();

            action2.stop();
            action2.toggled = false;

            action2.onRelease = function():Void {
            this.toggled = !this.toggled;
            if (this.toggled) {
            this.gotoAndStop(2);
            (volumeOn)
            globalVolume.setVolume(100)
            } else {
            this.gotoAndStop(1);
            globalVolume.setVolume(0);
            }
            volumeOn = !volumeOn;
            }