Unable to use event.target with ui.lua button functions

Any idea why event.target isn’t working for a function that handles a ui.lua button touch event?

Here’s my code, which is supposed to flash a button then change scenes:

function flash(object)  
 object.isVisible = not object.isVisible  
end  
function startGame( event )   
  
 if event.phase == 'release' then  
  
 local t = event.target  
  
 local flashItem = function() return flash(t) end  
 timer.performWithDelay(100, flashItem, 10)  
  
 local function changeScene()  
 director:changeScene("mainGame","moveFromRight")  
 timer.cancel(flashItem)  
 end  
  
 timer.performWithDelay(1000, changeScene, 1)  
 end  
end  

The button is set up like this:

onEvent = startGame  

This above code doesn’t produce any errors; it just switches immediately to the next scene with no delay or flashing.

The workaround I’m using is to explicitly call the button by name in the flash() function, like this:

local flashItem = function() return flash(startButton) end  

This method is fine since I only have two other menu buttons, but I’d like to know why I can’t get event.target to work.

Also, if anybody has a suggestion on how to do this more elegantly, I’m open. [import]uid: 10489 topic_id: 9283 reply_id: 309283[/import]