Skip to main content
Inspiring
February 26, 2010
Question

Capture the true FPS

  • February 26, 2010
  • 1 reply
  • 493 views

Hello everyone,

Now no doubt this has been a problem for a few people and I have trawled through a few web pages to try and find a solution. Is there a way of capturing the true running frames per second when a flash movie is playing?

That’s it really.

Thanks for all your help in advance.

This topic has been closed for replies.

1 reply

kglad
Community Expert
February 26, 2010

:

this.onEnterFrame = function(){

yourtextfield.text=1000/(getTimer()-startTime);

startTime=getTimer();

}

DazFazAuthor
Inspiring
February 26, 2010

Hi kglad,

Thank you for your reponse.

So to recap on your suggestion then:

this.onEnterFrame = function(){

     yourtextfield.text=1000/(getTimer()-startTime);

     startTime=getTimer();

}

1000; Im assuming here that this figure equates to 1 second in time terms

getTimer(); This will return the amount of milliseconds that the flash player has been running for

startTime; again this will return the time in milliseconds the flash player has been running for at that set point in time (second pass).

So in short:

this.onEnterFrame = function(){

     timeItsTakenToCallThisFunctionAgain = getTimer()-startTime

     framePerSecond = 1000/timeItsTakenToCallThisFunctionAgain

     startTime = getTimer();

}

This is leading somewhere becuase this calculation is not consistant when tested through the likes of MachBlue.

kglad
Community Expert
February 26, 2010

you wouldn't expect it to be consistant unless there's no change is system resources while that code is executing.  otherwise it shouldn't vary by more than 1 fps.

you can use Math.round() to eliminate fractional changes in the fps if that suits your needs.

p.s.  please mark this thread as answered, if you can.