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.
IndexProgramming Questions & HelpSyntax Questions › loadFont/loadImage from nested class
Page Index Toggle Pages: 1
loadFont/loadImage from nested class (Read 917 times)
loadFont/loadImage from nested class
Feb 23rd, 2010, 12:16pm
 
It appears I can't call loadFont or loadImage from the constructor of my own class (nested inside of the PApplet class). Or at least if I do, I need some other naming convention. I get the exception about not being able to find the font or image.

Is this supposed to work? Is there a way to make it work?
Re: loadFont/loadImage from nested class
Reply #1 - Feb 23rd, 2010, 9:48pm
 
It should work.  Can you paste the code?
Re: loadFont/loadImage from nested class
Reply #2 - Feb 23rd, 2010, 11:26pm
 
Ensure your object is created in setup(). If you create it as global variable, the constructor will be run before setup() is run, and sketch path (thus data folder path) won't be initialized yet.
Re: loadFont/loadImage from nested class
Reply #3 - Feb 25th, 2010, 3:53am
 
Thanks PhiLho.

I have just experienced the same problem and couldn't work out what was wrong until I found your reply to this thread.

I was creating the object at the same time as creating a global variable and it failed.

I moved the object creation into setup(), but left the object as a global variable and it worked.

Thanks

--
PenguinTutor
Page Index Toggle Pages: 1