2 Replies Latest reply on Aug 25, 2010 3:48 PM by wunderful61

    Sound restarting in wrong place

    wunderful61 Level 1

      I created a play/pause/track slider to control sound. No animation at all. With traces, I can see that the new sound position is being calculated correctly. When the sound restarts, it is much closer to the end of the sound than it should be. Snippets below:

       

        public function playAudio(event:Event = null):void
        {
         if(media.channel)
         {
          media.channel.stop();
         }
         media.channel = media.audio.play(media.soundResume);
        }
       
        public function pauseAudio(event:MouseEvent = null):void
        {
         controller.removeProgress(cntl_mc);
         media.soundResume = media.channel.position;
         media.channel.stop();
         if (SoundMixer.areSoundsInaccessible() == false)
         {
          SoundMixer.stopAll();
         }

      }
       
        public function processDragBar():void
        {
         pauseAudio();
         cntl_mc.progress_mc.bar_mc.startDrag(false, new Rectangle(0,0,cntl_mc.progress_mc.track_mc.width - cntl_mc.progress_mc.bar_mc.width, 0));

        }
       
        public function processDropBar():void
        {
         var percentage:Number = (cntl_mc.progress_mc.bar_mc.x / (cntl_mc.progress_mc.track_mc.width - cntl_mc.progress_mc.bar_mc.width));
         media.soundResume = (percentage * media.audio.length);
         playAudio();
         cntl_mc.progress_mc.bar_mc.stopDrag(); 
        }
       
        public function processTrack():void
        {
         cntl_mc.progress_mc.bar_mc.x = media.newTrackX;
         var percentage:Number = (cntl_mc.progress_mc.bar_mc.x / (cntl_mc.progress_mc.track_mc.width - cntl_mc.progress_mc.bar_mc.width));
         if (percentage >= 1)
         {
          media.soundResume = 0;
          pauseAudio();
         }
         else
         {
          media.soundResume = (percentage * media.audio.length);
         }
         playAudio();
        }