5 Replies Latest reply on Nov 12, 2007 10:46 AM by 3-Putt

    Sound Question

    3-Putt
      I have a bunch of sounds in a flash piece in multiple MC's and want to mute the sounds whenever the user would like. Is it just a matter of a button extending along the timeline and using stopAllsounds and playAllsounds?
      thx Brian
        • 1. Re: Sound Question
          Level 7
          3-Putt,

          > I have a bunch of sounds in a flash piece in multiple MC's and
          > want to mute the sounds whenever the user would like. Is it just
          > a matter of a button extending along the timeline and using
          > stopAllsounds and playAllsounds?

          There are a number of ways you might approach this goal, but I think
          ActionScript is the easiest, even if your current sound files aren't being
          presented via ActionScript.

          http://www.quip.net/blog/2006/flash/how-to-toggle-sound-globally

          Note, that's an ActionScript 2.0 tutorial, so if you're using AS3, let
          me know.


          David Stiller
          Co-author, Foundation Flash CS3 for Designers
          http://tinyurl.com/2k29mj
          "Luck is the residue of good design."


          • 2. Re: Sound Question
            silverSurfer
            try making this:
            first go to each sound in the library , right-click:linkage and click 'export for actionscript' checkbox. give each sound a unique name (lowercase no space of course)
            then in the first frame of your movie add this code
            // create ound object
            var mySound:Sound = new Sound()
            //now attach a sound linkage
            mySound.attachSound(linkageName)
            // now play it
            mySound.start()
            // you could use the last couple of lines anywhere in your timeline, just changing the linkage names to suit.
            cheers
            • 3. Re: Sound Question
              3-Putt Level 1
              I love the variation where you use just one button. Does that work as a multistate button. How does it show the music is off on the button with this script? Does it trigger the btnSoundOn when clicked again?

              Thanks for the insight,
              Brian
              • 4. Re: Sound Question
                Level 7
                Brian,

                > I love the variation where you use just one button.

                Cool. :)

                > Does that work as a multistate button.

                As in, does it toggle ... click it, it stays in; click it again, it
                releases? For that, you might want something like this:

                http://www.quip.net/blog/2007/flash/how-to-build-basic-toggle-as2

                > How does it show the music is off on the button with
                > this script?

                That script only shows how to change the volume. If you want a visual
                change on your button, you'll have to program for that, as shown above (just
                one way of doing it).

                > Does it trigger the btnSoundOn when clicked again?

                The one button version doesn't instruct btnSoundOn to do anything,
                though you certainly could have it to so. You could simply call that button
                symbol by its instance name -- btnSoundOn, if that's what it is -- and tell
                it what to do. You can find out what button are capable of in AS2 by
                looking up the Button class. You can find out what movie clips are capable
                of by looking up the MovieClip class. The Help docs are tightly organized
                around classes, which is a really helpful thing. Basically, you think about
                what object you're dealing with -- button, text field, movie clip, etc. --
                and look up the class that specifies the functionality of that object.
                Properties are characterstics of that object, methods are things it can do,
                and events are things it can react to.


                David Stiller
                Adobe Community Expert
                Dev blog, http://www.quip.net/blog/
                "Luck is the residue of good design."


                • 5. Re: Sound Question
                  3-Putt Level 1
                  That awesome...worked great. I also wrote you at your blog at http://www.quip.net/blog/. Shameless plug if you need it
                  thx brian