Here is a basic script for playing a sound:
Creating the sound object:
CODE
var _soundURL = SOME URL;
var netsound:Sound = new Sound();
netsound.loadSound(_soundURL, false);
netsound.setVolume(100);
var playingSound = 0;
var cue_point = 0;
Play button code (NOTE - This also acts as the paused button code)
CODE
playButton.onRelease = function() {
if(playingSound == 0){
//goto playing view
playingSound = 1;
netsound.start(cue_point);
}
else{
//goto paused/stopped view
playingSound = 0;
cue_point = netsound.position/1000;
netsound.stop();
}
}
Stop sound function:
CODE
function stopSound() {
if(cue_point != 0){
netsound.start(0);
cue_point = 0;
if(playingSound == 1){
playingSound = 0;
//Have the play button go to the paused/stopped view
}
netsound.stop();
}
}
That is the basics behind it, NOTE - You don't want to create a new sound object each and everytime you are playing the sound over, otherwise it WILL have the sounds overlapping. Create a single sound object outside of the functions.
Hope that helps.