BUG: transition onComplete doesn't pass event.target

I found a bug in transition.to, it doesn’t pass the object to onComplete function.

this example is taken directly from the corona docs…

local square = display.newRect( 0, 0, 100, 100 ) local w,h = display.stageWidth, display.stageHeight local listener1 = function( event ) local target = event.target print( "Transition 1 completed on object: " .. tostring( target ) ) end -- (1) move square to bottom right corner; subtract half side-length transition.to( square, { time=1500, alpha=0, x=(w-50), y=(h-50), onComplete=listener1 } )

The response is…

Transition 1 completed on object: nil

Wouldn’t an Event function need some kind of event phase to trigger it? I’d suggest trying it this way:

local listener1 = function( obj ) print( "Transition 1 completed on object: " .. tostring( obj ) ) end

I use these quite often to nil out objects and it seems to work pretty well. 

Hi @coolromin,

Apologies for this… the “onComplete” of transitions now behaves as in the 1.0 version of the library (for consistency), and I forgot to update the code sample in the transition.to() documentation. I’ll make this correction shortly. As @Panc suggests, use just the “event” (or whatever argument you want to name it), not “event.target”.

Brent

Wouldn’t an Event function need some kind of event phase to trigger it? I’d suggest trying it this way:

local listener1 = function( obj ) print( "Transition 1 completed on object: " .. tostring( obj ) ) end

I use these quite often to nil out objects and it seems to work pretty well. 

Hi @coolromin,

Apologies for this… the “onComplete” of transitions now behaves as in the 1.0 version of the library (for consistency), and I forgot to update the code sample in the transition.to() documentation. I’ll make this correction shortly. As @Panc suggests, use just the “event” (or whatever argument you want to name it), not “event.target”.

Brent