regarding disposal of temporary display elements

Ok. So what’s the best way to dispose of a simple text display element that you only want to appear briefly, do a transition and then disappear. for example:

function showFeedback(what)
local feedBackDisplay = display.newText( what,50 ,50, “myFont”, 30 )
transition.to(feedBackDisplay, {time=400, width=200, height=200})
end

I tried adding a onComplete: feedBackDisplay:removeSelf() but that executes before the transition even happens.

Should I declare “feedBackDisplay” as a global just to store it outside the function and then write a separate function to dispose of it?

Thanks for any insight! [import]uid: 6310 topic_id: 15247 reply_id: 315247[/import]

I think onComplete expects a function call.
try

onComplete = function () feedBackDisplay:removeSelf() end

so a complete transition call would look like this

transition.to(feedBackDisplay,{time = 400,width=200, height=200, onComplete = function () feedBackDisplay:removeSelf() end ;})  

should work…

-finefin [import]uid: 70635 topic_id: 15247 reply_id: 56296[/import]

Oh sweet!

Toto, we are not in ActionScript anymore!

Thanks! [import]uid: 6310 topic_id: 15247 reply_id: 56338[/import]