Dear all,
This is all about handling event listener I believe.
the case is , I have a button, everytime I click it, it will do something.
say:
local button = display.newRect(0,0,200,200)
function click (e)
local texttext = display.newText (“testestestest”, 0,0, native.systemFont,12)
timer.performWithDelay(1000,function()
texttext:removeSelf()
end,1)
end
button:addEventListener(“tap”,click)
so, it works properly. However, when I click the button frequently, error start to happen. It may due to the delay on respond of the timer. what I want is to make the button disable on that 1 sec (when timer counting), can it be done?
Again! Thanks Guys!!!
Dear all,
This is all about handling event listener I believe.
the case is , I have a button, everytime I click it, it will do something.
say:
local button = display.newRect(0,0,200,200)
function click (e)
local texttext = display.newText (“testestestest”, 0,0, native.systemFont,12)
timer.performWithDelay(1000,function()
texttext:removeSelf()
end,1)
end
button:addEventListener(“tap”,click)
so, it works properly. However, when I click the button frequently, error start to happen. It may due to the delay on respond of the timer. what I want is to make the button disable on that 1 sec (when timer counting), can it be done?
on the other hand, I want to set…remove the object if it is existed:
I have just tried:
if texttetxt ~= nil then
texttext:removeEventListener(“tap”,click)
end
but if texttext is alpha=0 or its isVisible is false, it will have error saying removeEventListener is nil.
Again! Thanks Guys!!!
Well I have figured out i can use the following code:
if texttext.isVisible then
texttext:removeEventListener(“tap”,click)
end
and it works @@
Dear all,
This is all about handling event listener I believe.
the case is , I have a button, everytime I click it, it will do something.
say:
local button = display.newRect(0,0,200,200)
function click (e)
local texttext = display.newText (“testestestest”, 0,0, native.systemFont,12)
timer.performWithDelay(1000,function()
texttext:removeSelf()
end,1)
end
button:addEventListener(“tap”,click)
so, it works properly. However, when I click the button frequently, error start to happen. It may due to the delay on respond of the timer. what I want is to make the button disable on that 1 sec (when timer counting), can it be done?
on the other hand, I want to set…remove the object if it is existed:
I have just tried:
if texttetxt ~= nil then
texttext:removeEventListener(“tap”,click)
end
but if texttext is alpha=0 or its isVisible is false, it will have error saying removeEventListener is nil.
Again! Thanks Guys!!!
Well I have figured out i can use the following code:
if texttext.isVisible then
texttext:removeEventListener(“tap”,click)
end
and it works @@