Parameters for onComplete?

Is there any way to add parameters to a function specified in onComplete in a transition.to? Here’s an example:

--just an example. Don't blame me if something is wrong. local function myFunction(obj) --code code code --used obj somewhere in this code end local objForFunction = display.newImage("image.png") transition.to(obj{alpha = 0.2, onComplete = myFunction(objForFunction)}) -- Can I have onComplete parameters?

I don’t really understand the docs for transition.to, so can anyone answer my question? Thanks.

You can do this:

[lua]transition.to(obj, {alpha = 0.2, onComplete = function() myFunction(objForFunction) end})[/lua]

jonjonsson is correct, but just to elaborate slightly: you CANNOT pass parameters directly into onComplete - the function will trigger instantly if you do, rather than at the end of the transition.

Passing a whole function into onComplete as jonjonsson has suggested lets you bypass this.

You can do this:

[lua]transition.to(obj, {alpha = 0.2, onComplete = function() myFunction(objForFunction) end})[/lua]

jonjonsson is correct, but just to elaborate slightly: you CANNOT pass parameters directly into onComplete - the function will trigger instantly if you do, rather than at the end of the transition.

Passing a whole function into onComplete as jonjonsson has suggested lets you bypass this.