13 Replies Latest reply on May 3, 2009 12:56 PM by kglad

    ActionScript fails to fire onSoundComplete function when playing local cont

    Viking46

      I have created a simple flash movie which I use to stream MP3 files into HTML documents using the JavaScript Flash integration Kit. When an audio file has finished streaming it fires the onSoundComplete function; using the integration Kit as a proxy allows me to fire JavaScript events within the HTML document. The event fires correctly when I am streaming from the Internet, however, it fails to fire when the movie and the files are on the same, local, machine.

      The problem lies, I think, in the following lines of code:

            sound.loadSound(url, true);
            sound.onSoundComplete = function(){
                  proxy.call("diceAudioFinished")
            }


      The full movie script is shown below.

      Can anyone tell me what the problem is please?

       

      ====================================================================

      Action script

      ====================================================================

       

      import com.macromedia.javascript.JavaScriptProxy;

       

      var proxy:JavaScriptProxy = new JavaScriptProxy(_root.lcId, this);

       

      var vol = 100; //the initial volume of the player

       

      /*
      *    increaseVol - used to increase the volume of the player by 10
      */
      function increaseVol(){
          if (vol == 100) return;
          vol = vol + 10;
          sound.setVolume(vol);
         
      }//end increaseVol

       

      /*
      *    decreaseVol - used to decrease the volume of the player by 5
      */
      function decreaseVol(){
          if (vol == 100) return;
          vol = vol - 10;
          sound.setVolume(vol);
         
      }//end decreaseVol

       

      /*
      *    audioStop - used to stop the current playback
      */
      function audioStop() {
          sound.stop();
          $marker = sound.position/1000;
      }

       

      /*
      *    audioPlay - used to create a sound object and
      *    start streaming the file (url)

      *    this function is called via the flash proxy from javascript
      *
      *    @param string url - url of the file to stream
      */
      function audioPlay(url){
          //if there is already a sound playing, stop it
          sound.stop();
          //delete the object
          delete sound;
         
          //create a new sound object
          sound = new Sound();
         
          sound.setVolume(vol);
          //here I am getting a sound from a url
          //and indicating that it is streaming (true)
          sound.loadSound(url, true);
          sound.onSoundComplete = function(){
              proxy.call("diceAudioFinished")
          }
             
      }