How can I stop a sound file from repeating when I don't want it to?

Hi guys!

I have a Flash banner, with a timeline that stretches to the length of the video clips inside. I’m calling a sound file with Actionscript which I’m using for background music. Here is the script that I’m using for that:


music = new Sound();
music.attachSound("SoundFile");
music.start(0, 999999);
music.setVolume(0);
vol = 0;

step = 3;
fade = 0;

onEnterFrame = function() {
  if (fade == 1) {
    vol = vol-step;

  if (vol<0) {
    vol = 0;
  }
  music.setVolume(vol);
  } else {
   vol = vol+step;
  if (vol>100) {
   vol = 100;
   }
  music.setVolume(vol);
  }
}

soundButton.onRelease = function() {
(_root.fade=!_root.fade) ? 1 : 0;

}

When my timeline reaches the end, the sound file restarts, whether or not the timeline restarts. I have a restart button that returns you to the beginning of the timeline, and when clicked, it returns you to the beginning of the timeline. When it reaches the frame with the Actionscript call for the sound file, the sound begins to play a second time over the first (which repeated unnecessarily). How can I stop the file from repeating? Is there any equivalent to PHP’s require_once(); that I could use here?

Any help is greatly appreciated!
Thanks

:bobafett: