removing object being dragged kills further dragBody events

Hi

i’ve got a demo where a bunch of objects fall from the sky. if they bounce off screen they get removed. if certain types touch they get removed.

The problem i’m seeing is that when i’m dragging a body and i either drag it off screen (killing it) or it collides with another and gets destroyed, then no further drag events work on the other objects

thanks for any info on how i might fix this
regards
j

[lua]for i=#ballsToRemove,1,-1 do

ballToRemove = ballsToRemove[i]

idx = TableUtils.indexof(balls,ballToRemove)
idx2 = TableUtils.indexof(ballsToRemove, ballToRemove)

if(ballToRemove~=nil) then

if(idx~=nil) then

– remove the sprite & physics

local sp = ballToRemove.sprite
sp:removeEventListener (“touch”, dragBody)
sp:removeSelf()

spriteCount = spriteCount - 1

– remove ball from ball arrays
TableUtils.splice(balls,idx)
TableUtils.splice(ballsToRemove, idx2)
end

end[/lua] [import]uid: 6645 topic_id: 3526 reply_id: 303526[/import]

also if i slow the frequency parameter down for instance, i seem t be able to draw multiple drag joints…(the blue lines on the crate) is this expected? shouldn’t it only let me add one?

also, using the simple reposition drag, not the gameUI drag, some times my mouse (in the simulator) leaves my object when i move it around fast without triggering an “ended” event. so the object stays where it is but it still thinks it’s being dragged. if i continue holding my mouse button down and drag back near it, it’ll pick it up again

i think it might be because there are objects being inserted in front of it regularly but i’m not sure

thanks for any help
j [import]uid: 6645 topic_id: 3526 reply_id: 10647[/import]

apparently the latter problem was a focus issue. i only wanted to remove focus if the currently dragged item was removed from the system

i fixed it with

[lua]local sp = ballToRemove.sprite
sp:removeEventListener (“touch”, dragBody)

if(_dragging == sp) then
sp.isFocus=false;
display.getCurrentStage():setFocus(nil)
end
sp:removeSelf()[/lua] [import]uid: 6645 topic_id: 3526 reply_id: 10650[/import]