Forum ActionScript 3.0 Exact Timing in Flash AS3

Problems and discussions relating to ActionScript 3.0 here.

Exact Timing in Flash AS3

Postby mfranzs » March 21st, 2011, 12:39 am

Hey-

I've been encountering a problem. Every 500 ms. my server sends a static update out. As well, every 50 ms., both my server and client run the game code that moves the players, etc. My problem is that on the server, the code is correctly running every 50 ms, so that the code runs 10 times before every static update. But, in the flash client, the setInterval() is not consistent, varying by about 30 ms. I've tried to use setTimeout() and subtracting the difference, so for example, if one timeout took 60 ms to trigger, the next timeout would be told to try to trigger at 40 ms. But, this method still has not worked.

Any ideas would be greatly appreciated :D
mfranzs
 
Posts: 98
Joined: August 29th, 2010, 3:27 am

Re: Exact Timing in Flash AS3

Postby Oliver » March 21st, 2011, 5:46 am

You have to design around the fact that timers, client and serverside, are not exact and probably won't execute *exactly* when you want them to.

I think in as3 you might be able to get better results if you increase the framerate of the flash file.

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Exact Timing in Flash AS3

Postby Benjaminsen » March 23rd, 2011, 9:15 am

Here is a very nice article that talks about how to work with timers and timesteps

http://gafferongames.com/game-physics/f ... -timestep/
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark


Return to ActionScript 3.0



cron