event.phase == "ended" <= don't work sometimes

I made a button by the code below. The A02(shadow button/over file) sometimes remains visible after pressing the button, I think it is because another button is pressed at the almost same time, so the [event.phase == “ended”] which make the A02 be not visible ailed to function.

How can I solve it? thanks a lot!

CODES ARE AS BELOW:

local A0 = display.newRoundedRect(30,260,36,260,7)

A0:setFillColor( 1 )

local A02 = display.newRoundedRect(30,260,36,260,7)

A02:setFillColor(0.9275, 0.9275, 0.9275)

A02.isVisible=false

A0effect = function(event)

if event.phase == “began” then

A02.isVisible=true

audio.play(A0Sound)

end

if event.phase == “moved” then

A02.isVisible = false

end

if event.phase == “ended” then

A02.isVisible=false

end

end

A0:addEventListener(“touch”,A0effect)

I’m not sure but you can try something like

A0effect = function(event) if event.phase == "began" then display.getCurrentStage():setFocus( event.target ) A02.isVisible=true audio.play(A0Sound) elseif event.phase == "moved" then A02.isVisible = false elseif event.phase == "ended" then A02.isVisible=false display.getCurrentStage():setFocus(nil) end end A0:addEventListener( "touch", A0effect )

sometime there the object lost the focalisation:

add this

elseif event.phase == "ended" or event.phase=="cancelled" then

But sometime it’s lost the focalisation and it’s not detect in ended or cancelled but we can’t do easly something for that. The problem is don’t often happen but only an update of Corona SDK can resolve that.

Thank you all !

It seems working after adding “return true” as the last line within the touch listener.

I’m not sure but you can try something like

A0effect = function(event) if event.phase == "began" then display.getCurrentStage():setFocus( event.target ) A02.isVisible=true audio.play(A0Sound) elseif event.phase == "moved" then A02.isVisible = false elseif event.phase == "ended" then A02.isVisible=false display.getCurrentStage():setFocus(nil) end end A0:addEventListener( "touch", A0effect )

sometime there the object lost the focalisation:

add this

elseif event.phase == "ended" or event.phase=="cancelled" then

But sometime it’s lost the focalisation and it’s not detect in ended or cancelled but we can’t do easly something for that. The problem is don’t often happen but only an update of Corona SDK can resolve that.

Thank you all !

It seems working after adding “return true” as the last line within the touch listener.