'Unhandle Exception. Attempt to access...

BlitzMax Forums/BlitzMax Programming/'Unhandle Exception. Attempt to access...

JoJo(Posted 2005) [#1]
...field or Method of Null object.
What am not getting. I don't see my mistake.

Strict
Graphics 640,480,0


'instantiate objects
Global imgBlue:Image= image.Create("gfx/blue.bmp")
Global imgGreen:Image = Image.Create("gfx\green.bmp")
Global imgYellow:Image = Image.Create("gfx\yellow.bmp")
Global imgRed:Image = Image.Create("gfx\red.bmp")
Global imgOrange:Image = Image.Create("gfx\orange.bmp")
Global imgPurple:Image = Image.Create("gfx\purple.bmp")

Global ImageList:TList = New TList	
Global ParticleList:TList = New TList

Type Image
	Global ImageListCount:Int =0
	Field xpos,ypos:Int
	Field _image:TPixmap = New TPixmap
	Field AlphaLevel:Int
	
	'create
	Function Create:Image(strPath:String)
		Local img:Image = New Image
		img._image = LoadPixmap(strPath)
		ImageList.AddLast img
		Return img
	End Function	
	
	
	'constructor
	Method New()
		ImageListCount:+1
		xpos = (GraphicsWidth() / 2)
		ypos = (GraphicsHeight() / 2)
	End Method
End Type

Local xpos,ypos:Int

While Not KeyDown(KEY_ESCAPE)
xpos:+1
ypos:+1
	DrawPixmap imgBlue._image, xpos, ypos
	Flip
Wend



skn3(Posted 2005) [#2]
You need to use the typename in a type function
Image.ImageList.AddLAst()


fredborg(Posted 2005) [#3]
Doh! Move the ImageList etc globals up before you load the images.


JoJo(Posted 2005) [#4]
Thanks! It was probably because I trying to do this half asleep at 3am.

Sometimes its always the simple things.