storyboard problem executes the function multiple times after reentry

Hello,
I add my function to the following section:
function scene:enterScene( event )

the function just prints a string to the console

when I exit the scene and reenter the scene and execute the function. It gets executed twice.
When I exit the scene again and reenter again and I execute the function it gets executed even more times and the times it gets executed grow everytime I exit reenter the scene.

How do i clear the function?

I I actually added the function name to the group:insert(functionName)
That actually works but also gives an error in the terminal.

What should I do to clear the function?

Thanks.

Seems I was missing the return true value in my functions.
Did not know you had to have that for it to work.

I have the same exact problem, and I don't understand what you did to fix it. Did you just put "return true" after all of your code in each of your scene:functions, or was that specific to your code?

This is the code:

function scene:enterScene( event )
local group = self.view

-----------------------------------------------------------------------------

-- INSERT code here (e.g. start timers, load audio, start listeners, etc.)

-----------------------------------------------------------------------------
text01 = display.newText( "hoofdletters", 100, 100, arial, 60 )
text01:setTextColor ( 255, 255, 255 )

local function LerenScherm(event)
if event.phase == "ended" then
storyboard.gotoScene( "hoofdMenu" )
print("herhaal")
end
return true
end

text01:addEventListener ( "touch", LerenScherm )

group:insert(text01)

end

without the return true it keeps repeating the text when you exit and reenter. With it no problem. So it seems.

Not sure if this is the solution. In another file I have it works for the audio not repeating but the text does get repeated.

That return true is specific to your code, so I don't know how it could help me. I wish someone would look at my thread. :P

I don't know if it is specific to my code. This is the simplest bit of code I could think of.
A back button and a text that gets printed.

Without the return true the text gets repeated, with it doesn't.

The actual code I use in my app is different, just needed some basic code to test the repeat printing.

views:1468 update:2011/12/28 9:26:54
corona forums © 2003-2011