onComplete - can I pass variables / arguments to the function?

I want to do something like this, onComplete=activateButtons(“game”), for a transition but it doesnt work.

Is there a correct way of doing the above? [import]uid: 5354 topic_id: 719 reply_id: 300719[/import]

Can you elab a bit more?

Carlos [import]uid: 24 topic_id: 719 reply_id: 1448[/import]

ok here goes

this works
transition.to(masterGroup, { rotation=90, time=400, delta=true, onComplete=backgroundOrientationReset } )

and calls the function backgrountOrientationReset() when the transition has completed

problem is that the function requires a variable to be passed like backgrountOrientationReset($foo), so the question is how do I pass $foo to the function call of the onComplete part of a transition? [import]uid: 5354 topic_id: 719 reply_id: 1451[/import]

One possibility is using a table:

local backgroundOrientationReset = { someParam = “default value” }

backgroundOrientationReset.onComplete = function( self ) print( self.someParam ) end

backgroundOrientationReset.someParam = “hello world”

transition.to(masterGroup, { rotation=90, time=400, delta=true, onComplete=backgroundOrientationReset } )
[import]uid: 5573 topic_id: 719 reply_id: 1453[/import]

Good question, and possible addition for the API?

I’m realizing that I need to get much more comfortable with Lua tables, but as an AS/Tweenlite fan, It would be great if Corona had an optional “onCompleteParams = []” syntax to send a comma separated list of property and values into the function.

transition.to(masterGroup, { rotation=90, time=400, delta=true, onComplete=backgroundOrientationReset, onCompleteParams=[aParam:$foo, bParam:$morefoo} ) [import]uid: 5339 topic_id: 719 reply_id: 1515[/import]

Great suggestion. Adding it to our feature list. [import]uid: 24 topic_id: 719 reply_id: 1522[/import]

Is there any news on this - the last post was in 2009. I saw nothing in the documentation.

Ultimately I need to loop an animation. Right now, I’m basically having a function be called with the transitions to loop & the iteration number & max iteration. Sadly this isn’t working. I can’t hard-code it as I’m doing a load from a JSON file. Any suggestions?

I tried the table mention above and it didn’t work. I’m new to LUA… [import]uid: 4289 topic_id: 719 reply_id: 79229[/import]

The [] syntax is invalid. It should be {}

But see this post:
http://blog.anscamobile.com/2011/02/using-closures-in-lua-to-avoid-global-variables-for-callbacks/
[import]uid: 7563 topic_id: 719 reply_id: 79242[/import]