1 Reply Latest reply on Oct 16, 2007 8:31 AM by clbeech

    action script for sound

    ceilifairy
      ok here is my goal.
      When a frame is loaded I want an mp3 to play but I only want it to play once. and NEVER again. Even if the frame is loaded again.
      What is the best way to achieve this?
      Thanks
        • 1. Re: action script for sound
          clbeech Level 3
          use:

          //if loading a streaming mp3 file from a directory
          var mySound = new Sound();
          mySound.loadSound('theFileName', true);

          //if loading a sound file from the Library with a linkage ID
          var mySound = new Sound();
          mySound.attachSound('sound_id');

          BUT, use a boolean conditional statement to limit the playing of the sound once, as in something like:

          if(!open) {
          var mySound = new Sound();
          mySound.loadSound('theFileName', true);
          open=true;
          }

          the first time the file is instatiated, 'open' will be undefined therefore satisfying the condition, but from that point forward while the file is running 'open' will become true, and will not load the sound again.