|
Author |
Topic: Null pointer in class (Read 267 times) |
|
sspboyd
|
Null pointer in class
« on: Aug 21st, 2004, 2:24am » |
|
My mistake. I was trying to load the objects into an array (Frame[]) before stating the size of the array Code:frames=new Frame[numFrames]; |
| ========== is there something obviously wrong with trying to create a new object from this Frame class Code:class Frame{ BImage img=new BImage(1024,768); String fn; Frame(String _fn){ fn=_fn; img=loadImage(fn); } } |
| i get null pointer exceptions when I call "new Frame("filename.jpg"); and I've double checked that the file exists and is in the right place.
|
« Last Edit: Aug 21st, 2004, 5:17am by sspboyd » |
|
gmail.com w/ sspboyd username
|
|
|
fjen
|
Re: Null pointer in class
« Reply #1 on: Aug 21st, 2004, 9:20am » |
|
Code: Frame f; void setup(){ size(100,100); f = new Frame("test.jpg"); } void draw(){ image(f.img,0,0); } class Frame{ BImage img=new BImage(1024,768); String fn; Frame(String _fn){ fn=_fn; img=loadImage(fn); } } |
| i have no problem using it .. no nullpointerexceptions from me.
|
|
|
|
|