Page 2 of 2

Re: Exact timing

Posted: Thu Jul 12, 2012 2:43 pm
by BvG
Another way to do it is to send much more messages, and use the milliseconds to time execution of the code. You will run into problems if your code takes longer to run then the alotted 700 milliseconds tho. As with all methods, this only gives somewhat of a precision, but no true precision can ever be achieved.

on mouseUp
send "doStuff" && the milliseconds to me in 70 milliseconds --fires 10 times too much
end mouseUp

on doStuff prevTime
if the milliseconds - prevTime >= 700 then
put the milliseconds into nextTime

--do stuff here

else
put prevTime into nextTime
end if
send "doStuff" && nextTime to me in 70 milliseconds
end doStuff

Re: Exact timing

Posted: Sun Jul 15, 2012 1:55 am
by Cool Dave
Okay,

It looks like there are several good (though lengthy) ways of doing it.

BTW, I just got 5.5, so now I can open your stacks. I also got Android, so I'll be in the Android Dev section mostly now.

You can see by the code and samples here that everyone does things a little differently. Funny how it's so much easier to read your own code, isn't it?

Thanks everyone for your answers and test stacks...Gotta love Livecode.
Dave