2 Replies Latest reply on May 16, 2016 8:43 AM by Sheena Kaul

    AS3 volume slider code not working

    uturn8 Level 1

      I added a volume slider that slides back and forth work but it doesn't change the volume. Am I doing it wrong or missing code? I am streaming different audio on each frame.


      Here is the code on the main timeline:



      var pP1:Number = 0;//playback position

      var playing1:Boolean = false;



      var mySound1:Sound = new Sound();

      var myChannel1:SoundChannel = new SoundChannel();

      mySound1.load(new URLRequest("Physiology Slide 01 INTRO.mp3"));

      myChannel1 = mySound1.play();






      function EnterFrame(event:Event):void {



      //chnange volume if the drag the volume slider

        var volumeLevel = myChannel1.soundTransform;

        var newLevel:Number = volumeSlider.slideKnob.x / 100

        volumeLevel.volume = newLevel;

        myChannel1.soundTransform = volumeLevel;




      PlayPause1_btn.addEventListener(MouseEvent.CLICK, togglePlay1);




      function togglePlay1(event:MouseEvent):void {

      playing1 = !playing1;

      if (playing1) playS1();

      else pauseS1();



      function playS1() {

      myChannel1 = mySound1.play(pP1);




      function pauseS1() {

      pP1 = myChannel1.position;