Attempt to access field or method of Null object

BlitzMax Forums/BlitzMax Beginners Area/Attempt to access field or method of Null object

MOBii(Posted 2014) [#1]
SuperStrict

Framework brl.System
Import maxgui.Drivers
Import brl.EventQueue
Import brl.PolledInput
Import brl.Max2D


Global Wello:TGadget		= CreateWindow(AppTitle, 100, 100, 320, 240)
Global Sub_Wello:TGadget	= CreateWindow("SUB", 430, 100, 320, 240, Wello, 1)
Global Tello:TGadget		= CreateCanvas(0, 0, ClientWidth(Sub_Wello), ClientHeight(Sub_Wello), Sub_Wello)	' NOT OK
'Global Tello:TGadget		= CreateTextArea(0, 0, ClientWidth(Sub_Wello), ClientHeight(Sub_Wello), Sub_Wello)	' OK

Rem
	I can CreateTextArea but CreateCanvas give this ERROR:
	AttachGraphics failed:Attempt to access field or method of Null object, What I do wrong?
End Rem

Repeat
	WaitEvent()
	Select EventID()
		Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE 		' [X] :: Quit Application
			If EventSource() = Wello Then
				Print "CLOSE :: Wello"
				End
			Else
				Print "CLOSE :: Sub_Wello"
				FreeGadget Sub_Wello
			End If
	End Select
Forever



MOBii(Posted 2014) [#2]
Sorry I didn't include:
Import brl.d3d9max2d
What is recommended if I want to do 2D tiles?
glmax2d or d3d9max2d?
Or is there alternatives?


Floyd(Posted 2014) [#3]
It's hard to know what you need to import with Framework. It's easier to let BlitzMax use the default "everything" method.
Once have a working program you can let Framework Assistant sort it out.

Edit: Don't know about the 2D tiles. If it's just for Windows then I would guess use D3D unless you have a good reason not to.
SuperStrict

Import maxgui.Drivers

Global Wello:TGadget		= CreateWindow(AppTitle, 100, 100, 320, 240)
Global Sub_Wello:TGadget	= CreateWindow("SUB", 430, 100, 320, 240, Wello, 1)
Global Tello:TGadget		= CreateCanvas(0, 0, ClientWidth(Sub_Wello), ClientHeight(Sub_Wello), Sub_Wello)	' NOT OK
'Global Tello:TGadget		= CreateTextArea(0, 0, ClientWidth(Sub_Wello), ClientHeight(Sub_Wello), Sub_Wello)	' OK

Rem
	I can CreateTextArea but CreateCanvas give this ERROR:
	AttachGraphics failed:Attempt to access field or method of Null object, What I do wrong?
End Rem

Repeat
	WaitEvent()
	Select EventID()
		Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE 		' [X] :: Quit Application
			If EventSource() = Wello Then
				Print "CLOSE :: Wello"
				End
			Else
				Print "CLOSE :: Sub_Wello"
				FreeGadget Sub_Wello
			End If
	End Select
Forever



GfK(Posted 2014) [#4]
You're better off not using Framework/Import at all, at first. Just get stuff working, then use Framework Assistant later.