Hello everyone 
i need to stop all my created objects, try this code and you will understand, it is simple, when active is equal to 1 i need to stop all my objects the default value of variable active is 0 and i can create and drag the objects but when i touche on the ball the active value is equal to 1 and i should not drag the objects, but it dont appear, i can drag the objects that was created before than i touch on the ball and the objects created after touch on the ball dont drag and it is good, only need to stop the drag objects created before touche on the ball. try the code to see the problem 
[code]
display.setStatusBar( display.HiddenStatusBar )
local physics = require “physics”
physics.start( true )
physics.setDrawMode( “normal” )
physics.setGravity( 0,0 )
–***************************************************
– Game
–***************************************************
local game = function()
local active = 0
print(active)
local ball1 = display.newCircle( 80, 120, 20 )
ball1:setFillColor( 0, 255, 0 )
physics.addBody(ball1,“kinematic”, { density=2, bounce=0.3, radius=25});
ball1.x = 250; ball1.y = 200
local spawner = display.newRect( 50, 5, 40, 40 )
spawner:setFillColor(150, 0, 0)
physics.addBody(spawner, “static”, {isSensor = true})
spawner:addEventListener(“collision”, spawner)
local function touch(event)
if event.phase == “ended” then
active = active + 1
print(active)
physics.setGravity( 0,9.8 )
ball1.bodyType=“dynamic”
end
end
ball1:addEventListener( “touch”, touch )
local block1 = {}
local spawnID = 0
local function spawnMyObject (event)
if event.phase == “began” then
spawnID = spawnID + 1
if #block1 < 3 then
block1[#block1+1] = display.newRect( 50, 50, 50, 50 )
block1[#block1]:setFillColor( 255, 255, 255, 100 )
block1[#block1].id = spawnID
physics.addBody(block1[#block1], “kinematic”, { density=2, friction=0, bounce=0, shape=barril })
block1[#block1].isFixedRotation = true
function spawner:collision (event)
if event.phase == “began” then
for i = 1, #block1, 1 do
if block1[i].id == event.other.id then
block1[i]:removeSelf()
table.remove(block1,i)
return true
end
end
end
end
local function startDrag( event )
local t = event.target
local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true
t.x0 = event.x - t.x
t.y0 = event.y - t.y
event.target:setLinearVelocity( 0, 0 )
event.target.angularVelocity = 0
elseif t.isFocus then
if “moved” == phase then
t.x = event.x - t.x0
t.y = event.y - t.y0
event.target.bodyType = “dynamic”
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
– Switch body type to kinematic, to avoid gravity
if ( not event.target.isPlatform ) then
event.target.bodyType = “kinematic”
end – last if
end-- 2º if “move” end
end --if begin
end – startdrag end
if active == 0 then
block1[#block1]:addEventListener(“touch”, startDrag)
elseif active == 1 then
block1[#block1].id:removeEventListener(“touch”, startDrag)
end
end – if #block end
end – 1º if “begin” end
end --spawnMyObject end
spawner:addEventListener(“touch”, spawnMyObject)
end–pausegame ()
game()
[/code] [import]uid: 26056 topic_id: 16429 reply_id: 316429[/import]

[import]uid: 26056 topic_id: 16429 reply_id: 61362[/import]