Scrolling on a canvas

BlitzMax Forums/BlitzMax GUI Programming/Scrolling on a canvas

Can anyone make this code work so that it scrolls smoothly ?
- at the moment it scrolls but it lags

Local x = GadgetWidth(Desktop())
Local y = GadgetHeight(Desktop())
'Graphics
Global background = LoadImage("background.jpg") 
'variables
Global mapXcenter = ImageWidth(background)/2
Global mapYcenter = ImageHeight(background)/2
Global characterX = 400
Global characterY = 300

Global Xoffset,Yoffset
Global ScrollBoarder = 100
'GUI
Local MyWindow:TGadget = CreateWindow("2DWindow",0,0,x,y)
Local MyCanvas:TGadget = CreateCanvas(0, 0 ,ClientWidth(MyWindow)-200  ,ClientHeight(MyWindow)  , MyWindow) 

Global mx:Int = 0
Global my:Int = 0
ActivateGadget MyCanvas
'MAIN LOOP
Repeat

 WaitEvent() 
 
  Select EventID()
  Case EVENT_WINDOWCLOSE
 	End
  Case EVENT_MOUSEMOVE
	
     mx=EventX()
     my=EventY()

	'scroll the map
	If EventX() < ScrollBoarder Then Xoffset:+10
	If EventX() > 800 - ScrollBoarder Then Xoffset:-10
	If EventY() < ScrollBoarder  Then Yoffset:+10
	If EventY() > 600 - ScrollBoarder Then Yoffset:- 10
		

	RedrawGadget(MyCanvas)	   

  Case EVENT_GADGETPAINT
 	SetGraphics CanvasGraphics (MyCanvas) 
	Cls
 	DrawImage background,(400-mapXcenter)+Xoffset,(300-mapYcenter)+Yoffset
	
	
	Flip

  
	
 End Select

Forever