When I touch the rectA and after I touch the rectB, rectA is released immediately. The error show in html5 but in android it work ok. Try code in below.
local rectA = display.newRect( 200, 200, 200, 200 ); rectA.name = "A" local rectB = display.newRect( 800, 200, 200, 200 ); rectB.name = "B" rectB:setFillColor( 1, 0, 0 ) local function tapControl( event ) local btn = event.target; if(event.phase == "began") then print( "tapControl", event.id, btn.name ) display.getCurrentStage():setFocus(btn, event.id); btn.hasFocus = true; btn.xScaleBefor, btn.yScaleBefor = btn.xScale, btn.yScale; btn:scale( 0.9, 0.9 ); elseif(btn.hasFocus) then if ( event.phase == "ended" or event.phase == "cancelled" ) then btn.xScale = btn.xScaleBefor; btn.yScale = btn.yScaleBefor; display.getCurrentStage():setFocus(btn, nil); btn.hasFocus = false; end end return true; end local function tapNew( event ) local btn = event.target; if(event.phase == "began") then print( "tapNew", event.id, btn.name ) display.getCurrentStage():setFocus(btn, event.id); btn.hasFocus = true; btn.xScaleBefor, btn.yScaleBefor = btn.xScale, btn.yScale; btn:scale( 0.9, 0.9 ); elseif(btn.hasFocus) then if ( event.phase == "ended" or event.phase == "cancelled" ) then btn.xScale = btn.xScaleBefor; btn.yScale = btn.yScaleBefor; display.getCurrentStage():setFocus(btn, nil); btn.hasFocus = false; end end return true; end rectA:addEventListener( "touch", tapControl ) rectB:addEventListener( "touch", tapNew )