button help

Is it possible to make it so that if you press a button but dont release it and just drag your finger off it, it has the same effect as releasing it. For example, I am using the code

local function presslevels (event)
	if event.phase == "began" then
		levelsbtn:setTextColor(247,117,9)
	elseif event.phase == "ended" or event.phase == "canceled" then
		levelsbtn:setTextColor(0,00,0)
	end
end

when I press and release the button, the text changes colour and then changes back again. However, if press it and then drag my finger and away, the text stays the new colour.

Try changing;
elseif event.phase == "ended" or event.phase == "canceled" then

To;

elseif event.phase == "ended" or event.phase == "canceled" or event.phase == "moved" then

Peach :)

Oh - OR - you may just want to use "tap" rather than "touch" - that way you don't have to play with event phases.

views:1828 update:2012/2/8 8:46:10
corona forums © 2003-2011