Dragging a new object just created

Hello,

I’m just starting some minor development to catch up Corona SDK.

My problem is being a drag body issue. I want to create an object when the user touch the screen, then that object, which was just created, should be moved if the user moves his/her finger. I took some code from an example called Multipuck.

Here you can see my code, I don’t know what’s wrong.

[lua]local function dragBodyDashboard( event )
if (event.phase == ‘began’) then
local dom = display.newImage( myImage )
dom:setReferencePoint(display.CenterReferencePoint)
dom.x, dom.y = event.x, event.y
physics.addBody( dom, { density=3.0, friction=0.5, bounce=0.3 } )
dom:addEventListener( “touch”, dragBody )
display.getCurrentStage():setFocus(dom, event.id)
end
end

local obj = display.newImage( myImageObj, 15, 15 )
obj:addEventListener( “touch”, dragBodyDashboard )[/lua]

I can move the object created if I give my finger up and then touch the screen again, but I got an offset regarding my finger.

I appreciate your help in advance. Thanks. [import]uid: 81082 topic_id: 16462 reply_id: 316462[/import]

I’ve already sorted it out.

Delete line 8, and include this piece of code instead:
[lua] event.target = dom
dragBody(event)[/lua] [import]uid: 81082 topic_id: 16462 reply_id: 61425[/import]