3 Replies Latest reply on Nov 7, 2007 6:41 AM by kglad

    AS3 + Control Sound Volume

    stormmedia Level 1
      Hi,

      I've been searching all over the internet and this forum for an answer on how to change the volume of a sound object in AS3.

      I have imported a .wav file into my library and have got the sound playing by targeting the class name I entered via the "Export for ActionScript" section within the .wav's Linkage.

      I gave the name "sMain" and my code is as follows....

      ////////////////////////////////////////////////////////////////////////////////////////// ///////////////////
      // PLAY BACKGROUND MUSIC
      var soundBg:Sound = new sMain();
      soundBg.play(0,100); // repeat sound 100 times
      ////////////////////////////////////////////////////////////////////////////////////////// ///////////////////

      But I can't work out how to change the volume so it's not playing at 100% (I need it playing at 70%).

      I've tried the following with no luck....

      ////////////////////////////////////////////////////////////////////////////////////////// ///////////////////
      // PLAY BACKGROUND MUSIC
      var soundBg:Sound = new sMain();
      soundBg.play(0,100); // repeat sound 100 times

      // SET THE VOLUME
      var myVol:SoundTransform = new SoundTransform();
      myVol.volume = 0.5;
      soundBg.soundTransform = myVol;
      ////////////////////////////////////////////////////////////////////////////////////////// ///////////////////

      Any help would be greatly appreciated!

      Kind regards,
      Mark