3 Replies Latest reply on Jun 29, 2006 5:44 AM by Newsgroup_User

    Setting Sound Levels

    meeesta
      Hello.

      I've got a main swf file which acts as like a hub, which then goes on to load a couple of external swf files. My problem is getting consistant sound across all the swf files. My hub (or _root) swf file creates a variable called soundLevel (which can be adjusted with volume controls).. this variable is then used across the board to define the level at which all sound should play.

      Except this is isn't the case.

      Any function that uses the following:

      volAudio.stop();
      volAudio.attachSound(whichSound);
      volAudio.start();
      volAudio.setVolume(_root.volumeLevel);

      Works fine, however in any of the external .swfs... when they reference this _root.volumeLevel variable I get a weird result.


      testAudio.attachSound(whichPlayList[playListCounter].clipName);
      testAudio.start();
      testAudio.setVolume(_root.volumeLevel);

      This code (in one of the external .swf files), when the sound level is seems to read _root.volumeLevel as a percentage of what soundLevel is already playing. So if I play one of the common sounds (from the hub) at say a level of 10, when I play a sound from an external .swf it plays it reads the _root.volumeLevel as a percentage... so it plays at 10% of 10... 1.

      Am I going about it wrong? Can I play sounds embedded in the external swfs via the _root hub .swf, would that fix the problem? Or can I have one global sound object instead?

      Any help or pointers would be greatly appreciated.

      Many thanks,
      Meeesta.


        • 1. Re: Setting Sound Levels
          ricklecoat Level 1
          Meeesta,

          My As knowledge is currently fledgling in the extreme, but if your theory about how the volume is being treated is correct, could you work around it by multiplying it upward? Eg:

          volFactor = _root.volumeLevel / 100
          newVol = 100*volFactor
          volAudio.setVolume(newVol);

          My code for this is probably wrong, but maybe you can see what I'm getting at. Tell flash to set the volume to x percentage of maximum volume, not x percentage of current volume.

          Of course, if there is a way to have the routine to behave as you originally expected, then that would be the much better option. Mine's a kludge.
          • 2. Re: Setting Sound Levels
            Level 7
            Meeesta,

            >> My problem is getting consistant sound across all
            >> the swf files. My hub (or _root) swf file creates a
            >> variable called soundLevel (which can be adjusted
            >> with volume controls).. this variable is then used
            >> across the board to define the level at which all
            >> sound should play.

            Instantiate a Sound instance without specifying a movie clip parameter
            in the constructor. Doing so causes that Sound instance to govern audio for
            the whole SWF, so just adjust the volume on that one.


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


            • 3. Re: Setting Sound Levels
              meeesta Level 1
              Thanks Ricklecoat.

              I ended up doing a fuzzy fix (or kludge as you put it)... I made all sounds in the external .swf s set at a volume of 100. Seeing as the they seemed to be working off the _root. sound volume level.

              And made sure all volume adjustments then only adjusted the root sounds and bingo... job done (sort of).

              I was just wondering if that is the way sound objects behave... and sound objects added to external movie clips.. will inherit the _root sound level.

              Anyhoo, thanks again.

              Regards,
              Meeesta