all groups > flash actionscript > july 2007 >
You're in the

flash actionscript

group:

assigning props/functions with for loop vs directly


Re: assigning props/functions with for loop vs directly David Stiller
7/13/2007 4:23:04 PM
flash actionscript: cayennecode,

[quoted text, click to view]

Heh, I've been known to loop for only three objects. It depends on how
much is going on with the various assignments. If they're long/complex
enough, a loop saves typing.

[quoted text, click to view]

In my experience, runtime performance isn't affected (or if it is, it's
affected a negligible amount). Dynamic assignment is an
author-time/programmer's convenience, and also comes in handy when the
number of objects to be assigned is unknown. Those are the primary benefits
I see.


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."

assigning props/functions with for loop vs directly cayennecode
7/13/2007 7:54:23 PM
Say you have X number of objects, and you want to assign a value to their
properties, or add an EventListener.

You could list all X number of objects, and set their property values as such
( objectX.property = value )

Of course that'd be silly if X number of objects was 100, or even 10...I'm
lazy.

So instead you put X number of objects into an array, and loop through that
array adding values to their properties.

I'm simply curious as to what runtime performance difference there would be.
Anyone tried anything like this, or care to speculate in theory?
Re: assigning props/functions with for loop vs directly cayennecode
7/13/2007 8:48:51 PM
[quoted text, click to view]

HAH! I hear that!


AddThis Social Bookmark Button