What are some expensive functions in AS3 and Flashpunk?


(Danny) #1

People often say “Try not to use X function too much it might affect performance”. I always read that Math.abs should be avoided, and that you should just use “(isNegative) ? -value : value”. What functions should I avoid (or use sparingly) to make my stuff more efficient?


(Zachary Lewis) #2

http://jacksondunstan.com/articles/413

If you want speed you should not be using plain functions, local functions, or Function variables. This should give some hint as to the speed of Flash’s package-level functions like getTimer(). Further, you can get big speedups by foregoing static functions, calls trough an interface, and calls through super, especially if you’re going to be using that convenience a lot. The rest of the functions are as fast as you can get. Don’t let anyone tell you that access specifiers matter, calling through this adds needless slowdown, functions should be final for speed, or overriding is handy but slow. It is handy, but it’s not slow.