4 Replies Latest reply on Apr 26, 2006 6:48 AM by skullnz

    setVolume on multiple sound objects

    skullnz
      Hi there

      I'm trying to use setVolume on individual sound objects. What I'm finding is that when I set the volume for one object, it sets it for all sound objects.

      My controlling script is a class object that defines a new sound object as a property of itself:

      this.sound_object = new Sound();
      this.sound_object.attachSound(this.sound_name);
      this.sound_object.setVolume(vol);

      Is this how it's meant to work? I'd be stoked if there was a way to control the volume of individual sound objects.
        • 1. Re: setVolume on multiple sound objects
          Level 7
          When you deal with sound objects, think of it as controlling the sounds
          playing in individual movieclips. Hence if you want to control the volume
          of various sounds separately you need to play these sound in different
          movieclips and create sound objects linked to the different movieclips too
          by doing:

          s = new Sound(target_mc);


          If you do not pass a target mc to the Sound Constructor, then the sound
          object will default to control the main timeline of your movie. If you
          create several sound objects like this:

          s1 = new Sound();
          s2 = new Sound();
          s3 = new Sound();

          They actually all control the same timeline which is probably not what you
          want to do.

          hth,
          Tim.




          • 2. Re: setVolume on multiple sound objects
            skullnz Level 1
            Some additional info:

            The createEmptyMovieClip() fix isn't working for me. This is what I tried:

            this.createEmptyMovieClip('sound_object', 50);
            this['sound_object'].attachSound(this.sound_name);
            this['sound_object'].start(0, 9999);

            ...but no sound would play.


            This is how my objects were originally structured:

            --+-- Object 1 (movieclip) -- Sound parent (movieclip) -- Sound object (property)
            ...|
            ..+-- Object 2 (movieclip) -- Sound parent (movieclip) -- Sound object (property)

            I don't see why these objects are interfering with each other, as there is definitely several layers of movie clip separating the two sound objects.
            • 3. Re: setVolume on multiple sound objects
              Level 7
              skullnz wrote:

              > this.createEmptyMovieClip('sound_object', 50);
              > this.attachSound(this.sound_name);
              > this.start(0, 9999);

              Blep! Wrong

              The point of creating the empty movieclip is so a timeline exists to play
              your sound. After that, you still need to create a Sound object to control
              the sound in that timeline. Hence the code should be:

              var mc = this.createEmptyMovieClip('sound_object', 50);
              this.s = new Sound(mc);
              this.s.attachSound(this.sound_name);
              this.s.start(0, 9999);

              Tim.


              • 4. Re: setVolume on multiple sound objects
                skullnz Level 1
                Gotcha! Cheers, that did the trick!