4 Replies Latest reply on Sep 22, 2006 3:57 AM by pall zoltan

    Multiple sounds cancelling each other out

    MakTheYak
      Hi all,
      I've got a little problem and hopefully someone will know what I'm talking about here...

      I have a music track in my movie which I want playing the whole time and then various different voice over tracks which come in at certain points in the movie. I load the music with attachSound and it starts playing fine. Then I load the first voice clip into an object with a different name and it plays just fine over the music. The problem comes, however, when I go to play the second voiceover clip. It completely cuts out the music track, for no apparent reason! It's always the second voiceover, irrespective of which clip I play or where it appears on the timeline.

      Any thoughts?

      Thanks!
        • 1. Re: Multiple sounds cancelling each other out
          MakTheYak Level 1
          Scratch that... I figured out what was making it stop. I have a new problem now: Why is it stopping?

          The voiceover is in a Sound object called my_sound and the music is called music. Why then, when I call my_sound.stop(); does it stop the music as well? That seems crazy to me!

          Ideas, anyone?
          • 2. Re: Multiple sounds cancelling each other out
            MakTheYak Level 1
            OK once again, scratch that - I figured it out. You have to specify the linkage ID as a parameter (Eg. music.stop("music"); ). Seems daft to me but who am I to question it?

            Next issue - Sound.setVolume(). Same thing is happening - I want to apply it to one Sound object but it's happening to all of them. But this time there's no option to supply the linkage ID. It's driving me crazy! Anyone who has come across this, please reply!!
            • 3. Re: Multiple sounds cancelling each other out
              MakTheYak Level 1
              OK folks well against the odds and despite all the time I've spent talking to myself on this board I've solved the problem. I didn't find it anywhere on the web - I figured it out myself - and so I'll post the answer here for completeness and so hopefully someone else will be able to benefit from it in the future.

              The trick is that when you set the volume on a sound object you are actually setting the volume on the movieclip that it's in. So if you attach your sound to _root and then setVolume on that sound, you are effectively setting the volume for the _root movieclip (ie the whole flash movie). You need to either create a new movieclip in the library and attach the sound in that or use createEmptyMovieClip() to make one on the fly with actionscript.

              Once it is created you need to refer to it when you create the sound object. Here's some example code:

              [code]
              createEmptyMovieClip("music", getNextHighestDepth());
              music.bgmusic = new Sound(_root.music);
              music.bgmusic.attachSound("bgmusic");
              music.bgmusic.start();
              music.bgmusic.setVolume(50);
              [/code]

              Make sure that the sound has linkage as "bgmusic" (or whatever you want to call it)
              • 4. Re: Multiple sounds cancelling each other out
                pall zoltan Level 1
                good to know, thanks :)