AS3 optimization

André Michelle released not just a very fast raycaster today but also made a very interesting post on the Flashforum. It is about the optimization of your AS3 code and I am in awe of his creative tests. The fastest method to fill an Array in AS2 was this one:

[as]var n: Number = 1000;
while ( –n > -1 )
array[ n ] = 0;[/as]

Now André just posted another method wich is a lot faster. The webcam with particles experiment moved from 25fps to 30fps.

This is what he posted and it describes the technique very well:

[as]var x: Number = 0;
while( x++ < 1000 )
{
// do something
}

var x: Number = 0;
while( x < 1000 )
{
x++;
// do something faster
}

// or inside conditions

if( ( z = iz * 100 ) < 0 )
{
// do something
}

z = iz * 100;

if( z < 0 )
{
// do something faster
}[/as]

Related Posts

0 Responses to “AS3 optimization”


  1. No Comments

Leave a Reply






Close
E-mail It