BUG: Transition cancel is not canceling the onComplete "queue" function list to be called

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

Renato,

Did this ever get fixed?  I am having a few problems with transitions… mostly that transition.cancel() is very SLOW. 

Hi cosmic.

That specific bug that I detailed above was fixed on daily build 2013.2085.

What daily build are you using?

But I may say that I am still seeing awkward behaviors with transitions in a game that I am developing. 

Thanks, Renato.  I am using build 2090.  The main problem I am seeing with transitions is the execution speed when canceling.  I got around the problem by using the tag system, ie: tag = “craftmove”, which allowed me to remove a bunch of transitions en mass.  When I tried to do it on a bunch of transition handles I had stored in a table, it was dog-slow.

How many transition are you talking about?  ~10 or ~100?

!250!

In my game I may have to cancel a quantity similar to that (when the user exit the game). I will keep a look on that and let you know.

Thanks, Renato!

I’m using the last public version and I wonder how to cancel a transition which didn’t start?

The following doesn’t stop the transition because it starts after 1 second, so how to do?

local t1=transition.to(obj, {time=1000, onComplete=onTransitionComplete})
transition.cancel(t1)

Hi @waltsir.

In your example, the transition is not starting after 1s. To do that you would need to use the “delay” property, not the “time” property (which defines the duration of the transition).

I tested here and you can cancel a transition that didn’t start without problem. I am using the daily build 2099 and 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, { delay=1500, x=50 , onComplete=onTransitionEnd }) transition.cancel(t1)

Thanks you right I made mistake between delay and time but with or without them the transition t1 is not cancelled since I see the printed text… (build 2076)

That bug was fixed on build  2013.2085.

ah ok, thank you to know this important bug is fixed :slight_smile:

Renato,

Did this ever get fixed?  I am having a few problems with transitions… mostly that transition.cancel() is very SLOW. 

Hi cosmic.

That specific bug that I detailed above was fixed on daily build 2013.2085.

What daily build are you using?

But I may say that I am still seeing awkward behaviors with transitions in a game that I am developing. 

Thanks, Renato.  I am using build 2090.  The main problem I am seeing with transitions is the execution speed when canceling.  I got around the problem by using the tag system, ie: tag = “craftmove”, which allowed me to remove a bunch of transitions en mass.  When I tried to do it on a bunch of transition handles I had stored in a table, it was dog-slow.

How many transition are you talking about?  ~10 or ~100?

!250!

In my game I may have to cancel a quantity similar to that (when the user exit the game). I will keep a look on that and let you know.

Thanks, Renato!