Hello! i have been programming an music player in flash as3. But i have some problems about it. The music player has a playlist generated by xml. But when you want to switch song and clicks on the song you want to hear, nothing happens. ahh hard to explain ill just show you.
http://www.emilnordh.se/mp3/mp3Player.swf test switch song by clicking on the text of the song. That doesn’t work right? then test by clicking just on the blue background of the song you wan’t to hear that’s working
When i do test it in flash i get this in my output:
TypeError: Error #1010: A term is undefined and has no properties.
at mp3Player/::playSong()
at mp3Player/::lal
so here is my code. i don’t think that i have done right with passing a name of evry movieclip.
private function xmlLoaded(evt:Event)
{
musicXML = new XML(evt.currentTarget.data);
for(var i:int = 0; i < musicXML.song.length(); i++)
{
songArray.push(new Song(musicXML.song*.@url, musicXML.song*.@artist, musicXML.song*.@title));
}
playSong(n++);
playList();
}
private function playSong(doWhat)
{
sound = new Sound();
sound.addEventListener(Event.SOUND_COMPLETE, soundComplete);
sound.addEventListener(ProgressEvent.PROGRESS, loadProgress);
sound.addEventListener(Event.COMPLETE, loadComplete);
doWhat;
if (n == songArray.length) n = 0;
if (n == -1) n = songArray.length;
else
trace(n);
sound.load(new URLRequest(songArray[n].url), new SoundLoaderContext(5000, false));
trace(n);
songText.txt.text = songArray[n].artist + " - " + songArray[n].title;
isPlaying = false;
}
private function playList()
{
for(var i:int = 0; i < songArray.length; i++)
{
var test = new playListAt();
test.txt.text = songArray*.artist + " - " + songArray*.title + " " + i;
test.y = i*40;
test.name = i;
test.addEventListener(MouseEvent.MOUSE_UP, lal);
test.buttonMode = true;
haaa.addChild(test);
}
}
private function lal(evt:MouseEvent)
{
if (channel)
channel.stop();
playSong(n = evt.target.name);
if(channel)
channel = sound.play(pausePosition);
isPlaying = true;
addEventListener(Event.ENTER_FRAME, playProgress);
}