Hello,

I wrote a routine that checks if the fps is below 45 fps for longer then 20 ticks, I toggle the quality of the SWF. If it then after is greater then 45 fps for 20 ticks I toggle quality back up.

It works, but out of interested, I was wondering if this could be done in a other more cleaver way then I did. Looking at the routine it feels very 'big', because I use 3 external vars and quite some code.

var treshold:Number = 20;
var buffer:Number = treshold;
var addValue:int;
function doProfiling(e:Event):void{
        if(fps>=45){
                addValue = 1
        }else{
                addValue = -1
        }
        buffer+=addValue
        if(buffer > treshold) {
                buffer = treshold;
        }else if(buffer < -treshold) {
                buffer = -treshold;
        }else if(buffer == 0) adjustQuality()
}

Cheers,

Jiri
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to