We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
PImage errors? (Read 230 times)
PImage errors?
Dec 15th, 2008, 3:41pm
 
I've been modifying my program and run into a strange error that I've yet to receive. Using processing 1.0.1

I declared a new PImage inside of my setup and then tried to reference it in my draw, yet it says "Cannot find anything named 'splashLogo'"  

The odd thing is I've got movies within my draw that load and play fine.  I tried moving the PImage declaration outside of the setup as a global and my file was not found, even though I can see it in the data folder.  If I declare the PImage inside the draw it loads as it should.  Any ideas?

Looks basically like this
Code:

void setup(){

PImage splashLogo = loadImage("mwvsplash.jpg");

}

void draw (){

if(tag == 0){
image(splashLogo, rectx, recty, rectWidth, rectLength);
}
}


Re: PImage errors?
Reply #1 - Dec 15th, 2008, 5:11pm
 
You have to use a mix of both:
Code:
// Declare outside of setup() so all functions can see it
PImage splashLogo;

void setup(){
// Initialize in setup because at above level,
// the data folder hasn't been checked yet (I think)
splashLogo = loadImage("mwvsplash.jpg");

}

void draw (){

if(tag == 0){
image(splashLogo, rectx, recty, rectWidth, rectLength);
}
}
Re: PImage errors?
Reply #2 - Dec 15th, 2008, 5:40pm
 
thanks again phil you are just as helpful as always
Page Index Toggle Pages: 1