miércoles, 20 de abril de 2011

Flash AS3 - FPS & Memoria Virtual

import flash.display.Sprite;
import flash.events.Event;
import flash.system.System;
import flash.text.TextField;
import flash.utils.Timer;
//
FPS()
//
var FPSs:uint = 0
var DisplayFPSs:TextField;
//
function FPS()
{
    DisplayFPSs = new TextField();
    addChild(DisplayFPSs);
    addEventListener(Event.ENTER_FRAME, onEnterFrameEventFPSs);
    var FPSsTimer:Timer = new Timer(1000,0);
    FPSsTimer.addEventListener("timer",onTimerEventFPSs);
    FPSsTimer.start();
}
//
function onEnterFrameEventFPSs(event:Event):void
{
    FPSs++;
}
//
function onTimerEventFPSs(event:Event):void
{
    DisplayFPSs.text="FPS :"+ FPSs.toFixed(1)+ " / "+ stage.frameRate + " Maximos" +
    "\nMemoria :"+(System.totalMemory/ 1024 / 1024 ).toFixed( 3 )+ "MB"
    FPSs = 0;
}