loading external data not working
hello! I'm relatively new with flash and actionscript, so this is my first question for you:
I have a listBox and I want to take data from a php file and insert it in my list box. But I am doing something wrong, because it's not working.
The php file retrives data in the following format:
echo "nrsongs=" . $nr_songs;
$i=0;
foreach($song_ids as $song_id){
$i++;
echo "&song_id" . $i . "=" . $song_ids[$i];
echo "&song_title" . $i . "=" . $song_title[$i];
echo "&song_artist" . $i . "=" . $song_artist[$i];
}
The php code works, if I call it directly in the url it retrives the data corectly.
So, here is my actionscript code:
loadAllLyrics();
var loadAllLyricsRequest:URLRequest = new URLRequest("lyrics.php?method=get");
var loadAlLyricsLoader:URLLoader = new URLLoader();
function loadAllLyrics()
{
lyricsList.removeAll(); // working
loadAlLyricsLoader.addEventListener(Event.COMPLETE, onAllLyricsLoaded);
loadAlLyricsLoader.load(loadAllLyricsRequest);
}
function onAllLyricsLoaded(evt:Event):void
{
var nr_songs:String = loadAlLyricsLoader.data.nrsongs;
var song_id:String = loadAlLyricsLoader.data.song_id1;
var song_title:String = loadAlLyricsLoader.data.song_title1;
var song_artist:String = loadAlLyricsLoader.data.song_artist1;
lyricsShow_txt.text = song_id + " " + song_title + " " + song_artist; // not working...
lyricsList.addItem(song_artist + " - " + song_title); // not working...
}
for simplicity I want to add only the first "song".