/** * DebugDisplayItemFPS * Displays the current realtime framerate * @author Zeh * @version 1.0 */ package com.zehfernando.display.debug { import flash.events.*; public class DebugDisplayItemFPS extends DebugDisplayItem { // Private properties protected var framesRendered:uint; // Number of frames rendered since the last update public function DebugDisplayItemFPS() { super(); } override protected function onTick(event:Event = null): void { super.onTick(event); framesRendered++; } override protected function update(timePassed:uint, includeInterval:Boolean = false): void { var fpsNow:Number; if (updateRate == 0) { fpsNow = 1000 / timePassed; } else { fpsNow = (framesRendered / timePassed) * 1000; } caption.text = String(Math.round(fpsNow)) + "fps"; timeGraph.push(fpsNow / stage.frameRate, includeInterval); } override protected function resetTimers(includeInterval:Boolean = false): void { super.resetTimers(includeInterval); framesRendered = 0; } } }