开发者

get machine time in air/as3

Is there a way to get a reliable machine time that cannot be altered by changing the time/date on a mobile device or computer?

I'm looking to find a way to see time elapsed in an air app where you can...

  • run the app
  • change the system time (back an hour, or change the date forward by two weeks, etc.)
  • run the app again with the correct time passed
  • 开发者_StackOverflow

any ideas how to implement this without relying on server connection?


I feel fairly confident saying it can't be done. Without a remote server to ping, all the app knows is what the OS tells it - and if the app isn't running, it can't be collecting its own data independently of the OS.

The closest you could get would be storing the system time at app shutdown, then comparing that to the system time on app startup to see if the OS' clock has been turned back - if the current time is before the previous time, you know something's up. Even then, the data about the last known system time has to be stored somewhere locally - which means the user is free to edit it if they want.

You could also mess with having the app running in the background constantly, or even as a service, though that moves out of the viability of using AIR - and even then, time would only pass while the system was on, and only if the user decides to let the background process continue running.


If your problem is measuring the elapsed time between two moments, getTimer should do the job.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜