4 Replies Latest reply on May 15, 2006 12:45 AM by STR Web

    Sound toggling on whole site?

    STR Web
      Hi,

      This is my first post on the forum, hope you may be able to help.

      I have an existing website made up of multiple pages (called into one flash movie), it has sound throughout the site on buttons and events etc.

      I have been asked to create a sound toggle for those people who may not wish to hear the sounds all the time.

      there are many easy ways to toggle a soundtrack but not multiple soundclips. The Stopallsounds script works but i need to turn them back on again as well.

      Any ideas?

      Thanks in advance
        • 1. Re: Sound toggling on whole site?
          Level 7
          STR Web,

          > I have been asked to create a sound toggle for those people
          > who may not wish to hear the sounds all the time.

          Okay.

          > there are many easy ways to toggle a soundtrack but not
          > multiple soundclips. The Stopallsounds script works but i
          > need to turn them back on again as well.
          >
          > Any ideas?

          Sure. You're dealing with sound, so look up the Sound class in the
          ActionScript Language Reference. Classes define objects, and just about
          everything useful in ActionScript can be referred to as an object. Things
          an object can do are called methods; characteristics it has are called
          properties; things it can react to are called events -- those are listed
          under headings in most class entries.

          You'll need to instantiate the Sound class and store a referece to it in
          a variable. Call the variable whatever you like. The constructor accepts a
          movie clip reference as a parameter, so if you type the following into the
          main timeline, use the word "this" (without quotes) as your reference,
          because that points to the main timeline (which is where the code is
          written).

          var globalVolume:Sound = new Sound(this);

          So we've delcared an arbitrarily named variable, globalVolume. It's a
          Sound data type, so the variable is followed by :Sound. To get a reference
          to a new Sound instance, we invoke new Sound() and pass in the main timeline
          as a parameter.

          Since the parameter is the main timeline, the properties of this Sound
          instance relate to the whole movie. Note the Sound.setVolume() method.
          Have one button provde the parameter 0 (zero) when invoking this method
          against the object; have another provide the parameter 100.

          btnSoundOff.onRelease = function() {
          globalVolume.setVolume(0);
          }

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


          --
          David
          stiller (at) quip (dot) net
          Dev essays: http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Sound toggling on whole site?
            TimSymons Level 1
            Instead of stopping the sounds you can try setting the volume to 0. If you create a new Sound() without a parameter then it will be aglobal sound control.

            var mySound:Sound = new Sound();
            mySound.setVolume(0); // Will set the volume of all sounds in the SWF to 0
            mySound.setVolume(100); // will set the volume of all sounds in the SWF to 100 (maximum level);

            Hope this gives you what you need.

            Tim
            • 3. Re: Sound toggling on whole site?
              Level 7
              Tim,

              > Instead of stopping the sounds you can try setting the
              > volume to 0. If you create a new Sound() without a
              > parameter then it will be aglobal sound control.

              Bingo. That's even better than my example, where I supplied "this" as
              the Sound constructor parameter.


              David
              stiller (at) quip (dot) net
              Dev essays: http://www.quip.net/blog/
              "Luck is the residue of good design."


              • 4. Re: Sound toggling on whole site?
                STR Web Level 1
                Thanks everyone, I will give it a go.

                Stuart