onComplete not behaving as expected.

I have the following simple code that transitions an image into view, then loads another image off screen after the transition is completed.

The behavior I am seeing on my lg android phone is that the image coming into view hesitates 3/4 of the way. Seemingly this is caused by the onComplete function firing before the transition is completed - not what I expected.

transition.to(xyz[2],{time = 150, x = _W*.5, onComplete = loadImgLast});

As a work around I removed the onComplete param and put in this code after the transition, which corrects the problem,

timer.performWithDelay( 225, loadImgLast)

I would like to know if anyone has any insight as to what may be causing this behavior.

[import]uid: 31039 topic_id: 11403 reply_id: 311403[/import]

I’d also like to know about this, I’m getting the same behaviour with a transition which should fade & then destroy the object.

transition.to(object, {time = 500, alpha = 0, onComplete = RemoveObject(object)})

as above the onComplete function fires instantly and destroys the object rather than it fading out then being destroyed.

EDIT: in my case the answer is here: http://developer.anscamobile.com/forum/2011/05/10/oncomplete-firing-immediately [import]uid: 68937 topic_id: 11403 reply_id: 42093[/import]

@ frankxyz
I’ve also noticed that transitions fading a display object’s alpha property to 0 don’t seem to reach 0 before calling the onComplete event.
@ matthewjhanlon, While you think you’re telling the transition to call “RemoveObject()” inside the onComplete event, you’re really telling it to call whatever “RemoveObject()” returns, which is probably nil after executing the RemoveObject code. Which is why you’re seeing it execute immediately.

It should be:

...onComplete=RemoveObject })  

or

...onComplete=function() RemoveObject(object) end })  

or

object.onComplete = RemoveObject ...onComplete=object }) [import]uid: 4596 topic_id: 11403 reply_id: 42121[/import]

I did a quick test of onComplete on Android device with build 552 and it does fire at the end of transition.to.

Here is my test code.

[code]
local circle = display.newCircle( 0, 100, 50 )
circle:setFillColor( 255,0,0 ) – red

– Change color after object finished move
local function changeColor( event )
circle:setFillColor( 0, 255,0) – green
end

transition.to( circle, {time = 2000, x = 270, onComplete = changeColor} )

[/code] [import]uid: 7559 topic_id: 11403 reply_id: 42743[/import]

I expect you’re loading the image in the onComplete. This is probably slowing down/freezing corona as the image loads. Image loading is pretty slow for large images on android.

Try preloading the image and setting its visibility to false, the trying the same code as a test case. [import]uid: 8872 topic_id: 11403 reply_id: 42753[/import]

My code was to show the onComplete listener fired at the end of the transition.to – when the object was on the right side of the screen. If it fired 3/4 the way, you would see the object turn green sooner.

If you have a small test case showing the problem, please submit the complete project as a bug report so we can pro properly log and track the problem. [import]uid: 7559 topic_id: 11403 reply_id: 42762[/import]