I'm trying to play more than one song in a music player. the music player is
in an exported movieclip and the links are in another movieclip.. but I kept
getting this error.. i did my research and found scripts online but no step
by step esplanation.. here is my code:
THIS IS MY CODE TO THE MUSIC PLAYER:
//var song:Sound = new Sound;
var sndChan:SoundChannel = new SoundChannel;
//var songReq:URLRequest;
var songPlaying:Boolean = false;
var pos:Number;
aPlayBtn.addEventListener(MouseEvent.CLICK, playSong);
aPlayBtn.buttonMode = true;
aStopBtn.addEventListener(MouseEvent.CLICK, stopSong);
aStopBtn.buttonMode = true;
aPauseBtn.addEventListener(MouseEvent.CLICK, pauseSong);
function playSong(e:Event):void {
if (songPlaying == false) {
songPlaying = true;
sndChan = MovieClip(root).audio.song.play(pos);
aPlayBtn.removeEventListener(MouseEvent.CLICK, playSong);
aPlayBtn.buttonMode = false;
}
}
function playSongI():void {
if (songPlaying == false) {
songPlaying = true;
sndChan = MovieClip(root).audio.song.play(pos);
aPlayBtn.removeEventListener(MouseEvent.CLICK, playSong);
aPlayBtn.buttonMode = false;
}
}
function stopSong(e:Event):void {
sndChan.stop();
songPlaying = false;
aPlayBtn.addEventListener(MouseEvent.CLICK, playSong);
aPlayBtn.buttonMode = true;
pos = 0;
}
function stopSongI():void {
sndChan.stop();
songPlaying = false;
aPlayBtn.addEventListener(MouseEvent.CLICK, playSong);
aPlayBtn.buttonMode = true;
pos = 0;
}
function pauseSong(e:Event):void {
pos = sndChan.position;
sndChan.stop();
songPlaying = false;
aPlayBtn.addEventListener(MouseEvent.CLICK, playSong);
}
AND THIS IS MY CODE TO THE MUSIC LIST:
var audioPlayer:aPlayer = new aPlayer();
audioPlayer.x = 50;
audioPlayer.y = 20;
var song:Sound = new Sound;
var songReq:URLRequest;
//BUTTONS HOLDING LOCATION OF SONGS--
btnStream01.addEventListener(MouseEvent.CLICK, onClick);
btnStream01.songURL = "audio/01 An Offer You Can't Refuse.mp3";
btnStream02.addEventListener(MouseEvent.CLICK, onClick);
btnStream03.songURL = "audio/02 Cruise.mp3";
btnStream03.addEventListener(MouseEvent.CLICK, onClick);
btnStream03.songURL = "audio/03 So Many Girlz featuring P. Murray.mp3";
btnStream04.addEventListener(MouseEvent.CLICK, onClick);
btnStream04.songURL = "audio/04 Damn I'm Cooo.mp3";
//---
function onClick(e:Event):void {
addChild(audioPlayer);
songReq = new URLRequest(e.currentTarget.songURL);
song.load(songReq);
this.audioPlayer.playSongI();
audioPlayer.aClosePlayer.addEventListener(MouseEvent.CLICK,
closePlayerFunction);
audioPlayer.aClosePlayer.buttonMode = true;
}
function closePlayerFunction(e:Event):void {
removeChild(audioPlayer);
this.audioPlayer.stopSongI();
}
--
____________
Reina Lyn Ben
Flash Web Devsigner
Web Portfolio: www.ReinaLynBen.com <http://www.reinalynben.com/>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders