I run the code below:
local function onTransitionEnd(event) print("onTransitionEnd - event=", tostring(event), "event.target=", tostring(event.target)) end local rect = display.newRect(0,0,1,1) print("rect=", rect) local t1 = transition.to(rect, { time=500, x=50 , onComplete=onTransitionEnd }) transition.cancel(t1) local t2 = transition.to(rect, { time=500, x=50 , onComplete=onTransitionEnd }) transition.cancel(t2) local t3 = transition.to(rect, { time=500, x=50 , onComplete=onTransitionEnd }) transition.cancel(t3) local t4 = transition.to(rect, { time=500, x=50 , onComplete=onTransitionEnd })
I was supposed to see the onComplete function only running 1 time, but it is being called 4 times, as you can see in the output below:
rect= table: 0x10112a380 onTransitionEnd - event= table: 0x10112a380 event.target= nil onTransitionEnd - event= table: 0x10112a380 event.target= nil onTransitionEnd - event= table: 0x10112a380 event.target= nil onTransitionEnd - event= table: 0x10112a380 event.target= nil
I already submitted this bug (Case #28044), please fix that asap, this is making my game crash.
I am using Corona Daily Build 2013.1235
In addition, the event params passed to the onComplete function is actually the event.target. So, the documentation (http://docs.coronalabs.com/api/library/transition/to.html) is not correct.
Renato