> As a relative newcomer to Actionscript, I have found the entirety of
> this thread very useful. I want to thank all of you for sharing this
> code, as well as providing a considerable amount of insight to those
> of us lurking in the shadows.
Glad to hear it.
> I was fairly surprised to see that if(this.length == 0) is considered
> sloppy opposed to (!this.length); conjointly, I had no idea that
> iterating through an array in the way you described was bad practice
> either. I'm sure I've done it quite a few times myself, unaware of the
> consequences.
The opposite. if (this.length == 0) is not sloppy code because it is
explicitly stating what you are expecting, versus accepting anything
that resolves as false in Flash, which includes 0, false, null and
undefined. You are being strict about what you expect and your code
will be easier to debug because of it, and you will be a stronger
programmer because you are well disciplined and don't take shortcuts
which could potentially come back to haunt you.
> It would be very beneficial for those of us who are not up to such
> (relatively) meticulous levels of coding practice if there was some
> sort of resource which enumerated a list of best coding practices when
> optimizing for speed--something along the lines of the similarly
> titled article in the flash documentation but aimed at the
> "middle-class" coder.
I know I don't have time to do this, and I've had to do my own research
over the years to find out this information, and that's fine by me
because it has made me a more resourceful developer. For loop speed has
been covered numerous times throughout the life of this mailing list and
searching the archives will shed light on lots of different things (use
google to search the archives, the built-in Flashcoders archive search
is broken).
And besides, if I say to you that this is the fastest for loop (but not
the fastest loop in Flash):
for (var i = len; --i -(-1); ) {}
You're going to ask why, especially given its funky syntax. Yes, it's a
for loop with only two parameters instead of three and the compiler has
no problem with it. The answer to why is explained by the guys who
wrote Flasm. If you want to learn more about how the Flash player works
and how to really optimize your code, check out Flasm.
Performance enchancers like putting the more likely result first in an
if statement, the fastest possible loop while(--a -(-1)), etc. are
explained by how Flash compiles your Actionscript into bytecode.
Anyway, good luck!
-Steven
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com