Since the clock sample does not actually work and just freezes after a short time I cannot make a functioning clock application - at least I don’t know how to.
Does anyone have a solution that they are using successfully to create a ‘run loop’ in their code.
If you look at sample code posted (at the link) you will see there is a timer running but the problem is the timer stops firing after about an hour. This was logged as bug #139 at the end of April and appears not to be fixed.
I think this posting was asking if anyone had a work-around for this bug.
Tom [import]uid: 6119 topic_id: 1052 reply_id: 2584[/import]
I ran the sample counter code on my iPhone using Corona 2.0 beta 3 and the counter stopped counting at 2880, which is 12 minutes (timer fires every 0.250 seconds).
I modified the code as Scott suggested to cancel and restart the timer every 5 minutes and the counter still stops at 2880.
What’s magical about 12 minutes?
Tom [import]uid: 6119 topic_id: 1052 reply_id: 2594[/import]
That’s actually some pretty good intel for the Ansca team I’d imagine. If that didn’t work, I’m really not sure what would other than waiting for Ansca to come up with a fix (or once they know the problem, a workaround).
I’d suggest you post your modifications to the counter code on the bug thread so they have another test case for the bug.
Scott [import]uid: 5659 topic_id: 1052 reply_id: 2596[/import]
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]