Thanks Lee. I didn't post first, because the code is long and has lots of stuff dealing with data mining etc. I made a minimal version of it. It gives me the same error. So maybe the error is not that bad, I'm just not a webprogrammer at all. I also tried loading the image in the makeFlags() method and passing it as a parameter, but it's still the same.
/*@pjs preload="flags/Syria.png,flags/Lebanon.png,flags/Algeria.png";*/
Flag [] flags;
String [] names = {"Algeria","Lebanon","Syria"};
int rowCount = names.length;
void setup(){
size(200,200);
makeFlags();
}
void draw(){
for (int i = 0; i < rowCount; i++) {
flags[i].render();
}
}
void makeFlags() {
flags = new Flag[rowCount];
for (int i = 0; i < rowCount; i++) {
flags[i]=new Flag(i, names[i]);
print("flags/"+flags[i].name+".png,");
}
}
class Flag {
PVector pos;
int id;
int[]stats;
String name;
int countryRisk;
int w, h;
PImage image;
public Flag(int index, String nm) {
pos = new PVector();
id = index;
name = nm;
String url = "flags/"+name+".png";
image = loadImage(url);
w =50;
h = 25;
float py = h*id + 50;
pos.y = py + id*10 ;
pos.x = random(width);
}
public void render(){
fill(60);
stroke(200);
if(image!=null){image(image, pos.x, pos.y, w, h);}
else {rect(pos.x, pos.y, w, h);println("NULL");}
//rect(pos.x, pos.y, w, h);