Quote from site I gave you
soundComplete Event
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.SOUND_COMPLETE
Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 9
Dispatched when a sound has finished playing.
The Event.SOUND_COMPLETE constant defines the value of the type property of a soundComplete event object.
This event has the following properties:
Property Value
bubbles false
cancelable false; there is no default behavior to cancel.
currentTarget The object that is actively processing the Event object with an event listener.
target The Sound object on which a sound has finished playing.
Example
In the following example, the user selects songs from a playlist, and then clicks Play to play the song in the order selected.
In the constructor, a text field is defined that holds the song list and a line for the selection to play. (Usually, buttons are used for play and list boxes for a song list.) A text format object is defined that changes the format of the song lines to italic after they are selected. When a user clicks the text field, the clickHandler() method is invoked.
In the clickHandler() method, the getLineIndexAtPoint() method of the text field object returns the index of the line where the user clicked. Using the line index, the getLineText() method gets the content of the text. The if statement checks whether the user selected to play a song or add a song to the play list. If a user has selected to play and a song has been selected, then the event listener for mouse click is removed and the playNext() method is called to begin playing the songs. If the user selected a song title, the content of the line is added to the songList array and the format of the line is set to italic.
The playNext() method iterates through the array list to load and play each song. The song is also assigned to a sound channel. An event listener for the sound channel is added to respond when the song finishes playing and the Event.SOUND_COMPLETE event is dispatched. The soundCompleteHandler() method then invokes the playNext() method to play the next song. This process continues until all the songs listed in the array finish playing.
package {
import flash.display.Sprite;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.events.MouseEvent;
import flash.text.TextFormat;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.IOErrorEvent;
public class SoundChannel_event_soundCompleteExample extends Sprite {
private var channel:SoundChannel = new SoundChannel();
private var songList:Array = new Array();
private var listTextField:TextField = new TextField();
private var songFormat:TextFormat = new TextFormat();
private var arrayIndex:int = 0;
private var songSelected:Boolean = false;
public function SoundChannel_event_soundCompleteExample() {
listTextField.autoSize = TextFieldAutoSize.LEFT;
listTextField.border = true
listTextField.background = true;
listTextField.text = "Song1.mp3
" + "Song2.mp3
"
- "Song3.mp3
" + "Song4.mp3
" + “PLAY”;
songFormat.italic = true;
listTextField.addEventListener(MouseEvent.CLICK, clickHandler);
addChild(listTextField);
}
private function clickHandler(e:MouseEvent):void {
var index:int = listTextField.getLineIndexAtPoint(e.localX, e.localY);
var line:String = listTextField.getLineText(index);
var firstIndex:uint = listTextField.getLineOffset(index);
var playLine:uint = listTextField.numLines - 1;
if((index == playLine) && (songSelected == true)) {
listTextField.removeEventListener(MouseEvent.CLICK, clickHandler);
playNext();
} else if (index != playLine) {
songList.push(line.substr(0, (line.length - 1)));
listTextField.setTextFormat(songFormat, firstIndex,
(firstIndex + listTextField.getLineLength(index)));
songSelected = true;
}
}
private function playNext():void {
if(arrayIndex < songList.length) {
var snd:Sound = new Sound();
snd.load(new URLRequest(songList[arrayIndex]));
channel = snd.play();
channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
arrayIndex++;
} else {
songSelected = false;
while(arrayIndex > 0) {
songList.pop();
arrayIndex–;
}
}
}
private function soundCompleteHandler(e:Event):void {
playNext();
}
private function errorHandler(errorEvent:IOErrorEvent):void {
trace(errorEvent.text);
}
}
}
Well, create a listener which would just set visible property of those buttons