2 Replies Latest reply on Jun 7, 2007 2:55 PM by jmoore09

    Audio issue

    jmoore09
      I need to control an audio file by keyframes so I am using the following script to start the audio file needed.

      s=new Sound(this);
      s.attachSound("soundID");
      s.start(0,999); // <- if you want this to loop 999 times

      I now need to stop this audio file when I get to a certain frame.

      Having trouble doing so. Any help would be greatly appreciated.

      Thanks
        • 1. Re: Audio issue
          Level 7
          If the sound object "S" is in the same timeline, then you could place a
          keyframe at the frame where you want the sound to stop and then place an
          action on that keyframe:

          s.stop();

          Alternately, you could use an enterframe function to look at the current
          frame number and execute the stop when the playback head reaches that
          frame:

          this.onEnterFrame = function() {
          if (this._currentframe == X) {
          s.stop();
          delete this.onEnterFrame;
          }
          }

          substitute the actual frame number for the "X" in the code above.
          • 2. Re: Audio issue
            jmoore09 Level 1
            Perfect. That was easy enough.

            Thanks Rob.