On 12/21/05, Mark Ribau <[EMAIL PROTECTED]> wrote:
> Anyone know of good optimizations to make to code so that it'll run
> faster in Flash?

functions: avoid, if at all possible.
methods of intrinsic classes are ok (e.g. Math.round()), but calling
an AS function  is very slow.
if you have to use functions, try to make them methods of some object
to force the compiler to use function2. i don't know what it depends
on, but i've found that declaring a function on its own sometimes
results in the normal function bytecode, which means there are only
four registers, so you rely on getVariable/setVariable which is slower
then registers (and with function2 you have 256 of them).

the fastest loop through an array is:
  var len = myArray.length;
  while( len-- ) {
    ...
  }
yes, it's faster then for..in.

it's been a while since i've tested it, but - is *slightly* faster than +.

use local vars. this is probably the most important one, apart from
avoiding functions.

accessing an array is *not* faster than accessing an object.

instead of
var foo = Math.floor( bar );
use
var foo = bar|0;

of course, what will bring you the most in performance is to improve
your algorithms and data structures.

wait for AS3.

hth,
mark

--
http://snafoo.org/
jabber: [EMAIL PROTECTED]
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to