5 Replies Latest reply on Feb 26, 2010 8:12 AM by kglad

    Capture the true FPS

    DazFaz Level 1

       

      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.

        • 1. Re: Capture the true FPS
          kglad Adobe Community Professional & MVP

          :

           

          this.onEnterFrame = function(){

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

          startTime=getTimer();

          }

          1 person found this helpful
          • 2. Re: Capture the true FPS
            DazFaz Level 1

            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.

            • 3. Re: Capture the true FPS
              kglad Adobe Community Professional & MVP

              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.

              • 4. Re: Capture the true FPS
                DazFaz Level 1

                Whilst testing a very similar script on an embedded system the detected frame rate, on a number or occasions jump up to 500+fps. Strange I know but this is why I’m asking the question about true frames per second.


                • 5. Re: Capture the true FPS
                  kglad Adobe Community Professional & MVP

                  you're doing something wrong.

                   

                  use exactly the code i gave (except you can rename the textfield).