Monday, September 3, 2012

Speed Test: Binding Math Functions to variables

I was surprised! Binding a Math library call to a function to avoid lookup using the dot operator did not result in a performance increase. In fact, just the opposite!
//result:
//Math_sqrt is about twice as SLOW as Math.sqrt
//I am suprised.

var Math_sqrt:Function = Math.sqrt;
var loopTimes:int = 54321;
var t1:int;
var t2:int;
var tt:int;
var ii:int;

t1 = getTimer();
for(ii=0; ii < loopTimes; ii++){
 Math_sqrt(ii);
}
t2 = getTimer();
tt = t2 - t1;
trace("Math_sqrt time==" + tt);


t1 = getTimer();
for(ii=0; ii < loopTimes; ii++){
 Math.sqrt(ii);
}
t2 = getTimer();
tt = t2 - t1;
trace("Math.sqrt time==" + tt);

Sunday, September 2, 2012

Turret Class Demo

Font embedding resources I found helpful:
ONE
TWO
THREE
However, I just ended up making a text object with all the characters
I needed to use and put it off screen on my .fla file to implicitly
embed the characters I needed.

Hackish, but the quickest and most reliable way to embed I know.

Lastly: Need to figure out why my filter effect takes about 10 seconds
to kick in when I embed my demo on the web. Yet when I test it on my
computer it runs immediately. There must be some minute difference in how
actionScript's virtual machine processes bitmap alphas on my computer vs
on the web.