5 Replies Latest reply on Jul 6, 2007 3:15 PM by kglad

    onsoundcomplete; onload

    nik c Level 1
      Hi,

      Maybe I am just having a mental block and can't see the wood for the trees. The issue is that I am creating a sound object inside a function, and start a sound playing. Then as long as I address the sound object from inside other functions it works fine, but not if I address it outside of one.

      Here is the code:

      quote:


      var currentSound=this.createEmptyMovieClip("mySoundShell",100000);
      var mySound;
      var moveScrubberInt:Number; // for a interval I am setting later

      function playAudio():Void {
      mySound = new Sound(currentSound);
      mySound.loadSound(contentArr[currentUnit][1][2], true);
      mySound.start()
      // get scrubber moving
      moveScrubberInt = setInterval(moveScrubber, 100);
      }
      mySound.onLoad = function(success:Boolean) { // the code in here does not get called at all
      trace("on load"); /
      var totalSeconds:Number = this.duration/1000;
      var minutes:Number = Math.floor(totalSeconds/60);
      var seconds = Math.floor(totalSeconds)%60;
      if (seconds<10) {
      seconds = "0"+seconds;
      }
      duration_txt.text = minutes+":"+seconds
      }
      mySound.onSoundComplete = function() { // the code in here does not get called at all
      clearInterval(moveScrubberInt);
      mySound.loadSound();
      timelineScrubber_mc.scrub_mc._x = 0;
      }



      but this code works fine:
      quote:


      //Pauses audio
      var pos;
      function pauseIt():Void
      {
      pos = mySound.position;
      trace("^^^^^^^^^^^^^^^pauseIt^^^^^^^ pos: " + pos);
      mySound.stop();
      clearInterval(moveScrubberInt);
      }



      Where is my block? Or what is going on here?

      I would be grateful for any hints?

      Thanks,
      Nik