1 Reply Latest reply on Jun 28, 2006 5:22 AM by Newsgroup_User

    Controlling A Single Sound

    sprackles Level 1
      Hi. I have created a CD ROM and am trying to iron out this glitch with my sound. I have a sound clip (trains.wav) that is activated when I play a small animation. I have a Stop button and a play button for this sound. This animation and sound is contained in a movie clip where i have created the variables sound on and sound off on a layer. For each button i call on these variables to turn the sound to 0 or to 100. e.g:

      layer code: var soundOff = new Sound(trains.wav);

      button code: on(Release){
      soundOff.setVolume(0)
      }

      This all works as expected. The problem is that I specify that the single sound is turned off as seen above, but when i go to play a video on a different movie clip, the sound is switched off here as well, and cant be turned on till i go back to the animation and click the sound on button? I really need help on code to toggle this one sound!
        • 1. Re: Controlling A Single Sound
          Level 7
          sprecks1,

          > For each button i call on these variables to turn
          >> the sound to 0 or to 100. e.g:
          >
          > layer code: var soundOff = new Sound(trains.wav);

          The Sound constructor takes a movie clip as its optional parameter.
          You're passing in what *might* be a movie clip -- a nested structure where
          one clip's instance name is "wav" inside another whose instance name is
          "trains" -- but my hunch is that you're passing in the name of your sound
          file. By doing that, you're effectively attaching your Sound instance to
          the whole movie, as if you had left the parameter out altogether. Note the
          difference here:

          var soundOff = new Sound(someMovieClip);
          soundOff.loadSound("trains.wav"); // this must be linkage id

          Now, your sound is associated with a clip instance named someMovieClip.
          when you set its volume to zero ...

          on (release) {
          soundOff.setVolume(0);
          }

          ... you'll only be addressing the sound associated with that clip.


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