Button Area. keep on working when i leave.

hey guys, its my first topic. sorry if it is in the wrong place.

when I touch my button, it performs the action, but if i slide the touch without lifting the screen, it keeps on performing.

What i want it to do is to stop performing when the touch goes out the button area.

If anyone can help me…

here’s the button’s code:

rightArrow:addEventListener(“touch”,pressRightArrow)

function pressRightArrow(event)

    print(“touch”)

   if event.phase == “began” then

        print(“scroll”)

        

        display.getCurrentStage():setFocus(event.target)

        event.target.isFocus=true

            

        

        --going right        

        base1.enterFrame = scrollScene

        Runtime:addEventListener(“enterFrame”, base1)

        

        base2.enterFrame = scrollScene

        Runtime:addEventListener(“enterFrame”, base2)

        

        redcac.enterFrame = scrollredcac

        Runtime:addEventListener(“enterFrame”, redcac)

        

   end

   

   if (event.phase == “ended” or event.phase ==“canceled”) and event.target.isFocus == true  then 

       print(“ended”)

          Runtime:removeEventListener(“enterFrame”, base1)

       Runtime:removeEventListener(“enterFrame”, base2)

       Runtime:removeEventListener(“enterFrame”, redcac)

       

       display.getCurrentStage():setFocus(nil)

       event.target.isFocus=false

    

    

   end

end

misspelled cancelled

maybe this is your problem…
    display.getCurrentStage():setFocus(event.target)
investigate about it friend :slight_smile:

thank you guys, it 's working now

misspelled cancelled

maybe this is your problem…
    display.getCurrentStage():setFocus(event.target)
investigate about it friend :slight_smile:

thank you guys, it 's working now