Jeg har en lille enkel mp3-afspiller, som i og for sig virker fint. Men den loader og begynder at afspille sangen når den loader swf-filen. Den skal bare tie stille indtil nogen klikke på play. How to? Koden kommer her:

var snd:Sound = new Sound(); //Create a new sound object
var sndFile:String;
var sndPlaying:Boolean = true; //Status flag indicating whether the sound is playing or not
var sndFinished:Boolean = false; //Status flag indicating whether the sound has finished playing or not
var sndVolBackup:Number; //Soubd volume before mute
var sliderLeft:Number = mcVolumeSlide._x; //Left coordinate of the volume slider drag area
var sliderTop:Number = mcVolumeSlider._y; //Top coordinate of the volume slider drag area
var sliderRight:Number = mcVolumeSlide._x + mcVolumeSlide._width - mcVolumeSlider._width; //Right coordinate of the volume slider drag area
var sliderBottom:Number = mcVolumeSlider._y; //Bottom coordinate of the volume slider drag area
var sliderClicked:Boolean = false; //Status flag indicating whether the volume slider is draged or not
var startVolume:Number = 50; //Start value of sound volume
var sndMute:Boolean = false; //Status flag indicating whether the sound is muted or not

//Extract the sound file name from the calling object
if (this.sndfile != undefined) {
sndFile = this.sndfile;
}
else {
//Default setting is song.mp3
sndFile = "http://ipaper.ipapercms.dk/ViewFile32403.mp3";
}

snd.loadSound(sndFile, true); //Load the specified sound file and start streaming
txtTime.htmlText = "00:00"; //Update the time tracker
snd.setVolume(startVolume); //Set initial sound volume
sndVolBackup = snd.getVolume(); //Backup the current sound volume value
mcVolumeSlider._x = mcVolumeSlide._x + ((sliderRight - sliderLeft) * snd.getVolume()) / 100; //Position the volume slider as corespondingly to the set volume
stop();

snd.onSoundComplete = function() {
sndPlaying = false;
sndFinished = true;
}

onEnterFrame = function() {
var temp:Number;

if(sliderClicked == true) {
//The volume slider is being draged, update volume
temp = ((mcVolumeSlider._x - sliderLeft) / (sliderRight - sliderLeft)) * 100;
snd.setVolume(temp);
}

//Update the time tracker
//Update the minutes
temp = Math.floor(snd.position / 60000)
if (temp < 10) {
//Display leading zero
txtTime.htmlText = "0" + temp + ":";
} else {
txtTime.htmlText = temp + ":";
}

//Update the seconds
temp = Math.floor(snd.position / 1000) - (Math.floor(snd.position / 60000) * 60)
if(temp < 10) {
txtTime.htmlText += "0" + temp;
} else {
txtTime.htmlText += temp;
}
}

mcPlay.onRelease = function() {
if(sndPlaying != true) {
if(sndFinished == true) {
//Start playing the sound from the beginning
snd.start(0);
} else {
//Start playing the sound only if it was previously paused
snd.start(snd.position / 1000);
}
sndPlaying = true;
sndFinished = false;
}
}

mcPause.onRelease = function() {
//Pause sound playing
snd.stop();
sndPlaying = false;
}

mcSpeaker.onRelease = function() {
//Mute the sound
sndVolBackup = snd.getVolume();
snd.setVolume(0);
this._visible = false;
sndMute = true;
}

mcSpeakerOff.onRelease = function() {
//Return the volume to its previous value
snd.setVolume(sndVolBackup);
mcSpeaker._visible = true;
sndMute = false;
}

mcVolumeSlider.onPress = function() {
if(sndMute != true) {
//Only allow volume slider dragging if the sound is not muted
this.startDrag(false, sliderLeft, sliderTop, sliderRight, sliderBottom);
sliderClicked = true;
}
}

mcVolumeSlider.onRelease = mcVolumeSlider.onReleaseOutside = function() {
//The user released the volume slider
if(sndMute != true) {
stopDrag();
sliderClicked = false;
}
}