Please help! About dragging images.

So I’m trying to make a jigsaw puzzle for a school project. I’m a total newbie and so i decided to first learn how to move images. I have found how to drag objects. I could make the squares draggable. The question is, what if it’s images?? 

This is the code I have derived from the tutorial. I’m having errors and I can’t make it work. Please help.

local image = display.newImage ("sample/puzzle1.png") function image:touch( event ) if event.phase=="began" then self.previousX = self.x self.previousY = self.y elseif event.phase=="moved" then local x = (event.x - event.xStart) + self.previousX local y = (event.y - event.yStart) + self.previousY self.x, self.y = x, y end return true end image:addEventListener("touch", image)

And while I’m at it, if there’s a kind soul who will give me tips on how to set them into collisions, i would be really grateful! Thanks a lot!