Here is some code that has been running over an hour on my 3GS iPhone. It uses “enterFrame” instead of a timer to update the counter. (The timer code stops counting after 2880 count – 12 minutes.)
-- Seconds Clock
-- infinite timed count
--
-- Corona bug #139 - test code
system.setIdleTimer( false ) -- turn off device sleeping
local counter = 0
local frameCount = 0
local clockTimer
local countField = display.newText( tostring(counter), 150, 190, "Arial-BoldMT", 48 )
countField:setTextColor( 255, 255, 255 )
local numField2 = display.newText( "v1.01", 10, 450, "Arial-BoldMT", 12 )
numField2:setTextColor( 255, 255, 255 )
-- This function is called for every frame
-- Updates the on screen counter every second.
--
--\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
local function updateCount()
--\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
frameCount = frameCount+1
-- Update counter every second (assuming 30 FPS)
if ((frameCount % 30) == 0) then
counter=counter+1
countField.text = tostring(counter)
print "Update"
end
end -- updateCount
Runtime:addEventListener( "enterFrame", updateCount )
--clockTimer = timer.performWithDelay( 250, updateCount, 0 )
Tom [import]uid: 6119 topic_id: 1052 reply_id: 2603[/import]