This has to be a classic beginners problem, but I can't solve it!
I need to load 10 or so image files. I used to have this:
try{
myimage = Image.createImage( "/graphics.gif");
}catch(IOException ioex){
dPrint("Exception " + ioex + " attempting to load " + sFileName);
}
and it worked. But it's a bit tacky having 10 of those, so I parameterized it, so I pass in a string. Declaration:
public Image loadImage(String sFileName)
then an init:
Image imTemp=null; // this is needed to prevent `possibly unused var `errors
and the offending line:
imTemp = Image.createImage(sFileName);
It seems the filename is being passed in properly, but all I get assigned to imTemp is a null.
What am I doing wrong? I just want a function where i pass in a filename as a string, and have it return an image containing the result of createImage.

Reply With Quote

