Thanks for your response Kerry.

On May 2, 2010, at 4:44 PM, Kerry Thompson wrote:

Karl DeSaulniers wrote:

Is there a document or website or page on adobe that I can go to that has
"all" the best practices for coding in AS2 and AS3?

There are a couple on the Adobe Web site. ActionScript 2 best
practices are at
<http://www.adobe.com/devnet/flash/articles/as_bestpractices.html>.
ActionScript 3 best practices are at
<http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/ html/wwhelp.htm?context=LiveDocs_Parts&file=00001090.html>.

If you Google "ActionScript best practices" you'll find a variety of
blogs and articles.

Yes, I will be doing a lot of this. :)


I can give you a couple that will speed up your code. First, use the
ActionScript classes as much as possible. They are compiled to native
code, and will run anywhere from 10 to 400 times as fast as any code
you can write, simply because the code your write gets compiled to
tokens, or bytecode, which then have to be interpreted at run time.
AS3 has a just-in-time compiler that helps, but there is still nothing
like native code.

I See


In loops, always store the end condition in a register variable. For
example, instead of this:

for (var i:int = 0; i<myArray.length; i++)
{
   do stuff;
}

do this:

var arrLen:int = myArray.length;

for (var i:int=0; i<arrLen; i++)
{
   do stuff;
}

Perfect. I had been doing it the worng way in some of my files.
I will be making this change immediately. Thanks for the laymen eg.


I know that runs faster in AS2. I haven't run tests in AS3, but I
would guess the JIT compiler would speed up either way of doing it,
but the second would still be faster.

Every little bit helps. I plan on making a collection of the info I have found.
Putting up a page on my website to find stuff like this.

Thanks again,
Best,

Cordially,

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

Karl DeSaulniers
Design Drumm
http://designdrumm.com

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

Reply via email to