hi again.
i wonder how to get XMLElement to work inside a class.
i had it inside a function and it worked just fine. but since the xml-thingy takes quite a while to load i wanted to multithread it so i can display a loading screen or something thelike.
unfortunately if i put it inside a class it doesn't work anymore. i think it's because in the previous version i had xmlartisttag = new XMLElement(this, getthisartist); and inside a class the "this" won't work...but xmlartisttag = new XMLElement(getthisartist); will start the application but will then "crash" because it can't parse.
inside multithreaded class:
Quote:
class CL_artisttagloader extends Thread{
XMLElement xmlartisttag;
public void run() {
for (int i = 0; i < artistnum; i++)
{
Curstatus = "Searching Tags for "+personalcharts[i].artist;
String getthisartist = convertencoding(personalcharts[i].artist);
getthisartist = "http://ws.audioscrobbler.com/1.0/artist/"+getthisartist+"/toptags.xml";
println(getthisartist);
try {
xmlartisttag = new XMLElement(getthisartist);
} catch (Exception e)
{
println(e);
}
int numartisttag = xmlartisttag.getChildCount();
println(numartisttag);
if (numartisttag >= 1) {
XMLElement artisttag = xmlartisttag.getChild(0);
XMLElement kidartisttag = artisttag.getChild("name");
personalcharts[i].tag = kidartisttag.getContent();
println(personalcharts[i].artist+" "+personalcharts[i].tag);
}
}
sortbytag(artistnum);
}
}
old version that worked fine (but alas without multithreading):
Quote:
void artisttagloader(int numartists){
for (int i = 0; i < numartists; i++)
{
Curstatus = "Searching Tags for "+personalcharts[i].artist;
String getthisartist = convertencoding(personalcharts[i].artist);
getthisartist = "http://ws.audioscrobbler.com/1.0/artist/"+getthisartist+"/toptags.xml";
println(getthisartist);
xmlartisttag = new XMLElement(this, getthisartist);
int numartisttag = xmlartisttag.getChildCount();
if (numartisttag >= 1) {
XMLElement artisttag = xmlartisttag.getChild(0);
XMLElement kidartisttag = artisttag.getChild("name");
personalcharts[i].tag = kidartisttag.getContent();
println(personalcharts[i].artist+" "+personalcharts[i].tag);
}
}
sortbytag(numartists);
}
tried using revision 136 but it somehow doesn't work. copied the revision 136 xml libraries over to my revision 135 but it didn't help.