Trying to make navigation disappear after 5 seconds of activity

Trying to make it navigation disappear after 5 seconds of inactivity. The process is that the user touches the screen, and navigation and TOC appear. If they don’t perform an action, I want the navigation to diappear. The problem is that i can’t figure out how to pause/restart the timer when they take action on the nav. Plus i’m getting out of memory issues. Any suggestions would be greatly appreciated.

[code]
module(…, package.seeall)

– Main function - MUST return a display.newGroup()
function new()
local localGroup = display.newGroup()

– Background
local background = display.newImage(“images/navpage.png”)
localGroup:insert(background)


local showSlider = require(“displaySlider”)
local showNav = require(“displayNav”)
local showTOC = require(“displayTOC”)

– Swipe to show next page or press to show navigation (slider for now)

local function backgroundt ( event )
if event.phase == “ended” then
if event.xStart > event.x then
showSlider:removeSlider()
showTOC:removeTOC()
director:changeScene(“play”,“moveFromRight”)
elseif event.xStart < event.x then
showSlider:removeSlider()
showTOC:removeTOC()
director:changeScene(“play2”,“moveFromLeft”)
elseif event.xStart == event.x then
– on touch show the stuff, but then need to set a flag in order verify if its already shown if they touch again.

showTOC:displayTOC()
showSlider:displaySlider()
timer.performWithDelay( 500, showSlider, 50 )

end
end
end

background:addEventListener(“touch”,backgroundt)

function showSlider:timer( event )
local count = event.count

print( “Table listener called " … count … " time(s)” )
self.text = count

if count >= 5 then
timer.cancel( event.source ) – after the 20th iteration, cancel timer
showSlider:removeSlider()
showTOC:removeTOC()

end
end
unloadMe = function()
end

– MUST return a display.newGroup()
return localGroup
end
[/code] [import]uid: 16420 topic_id: 11108 reply_id: 311108[/import]