Re: Exact timing
Posted: Thu Jul 12, 2012 2:43 pm
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
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