0
assigning props/functions with for loop vs directly

/t5/animate-discussions/assigning-props-functions-with-for-loop-vs-directly/td-p/282890
Jul 13, 2007
Jul 13, 2007
Copy link to clipboard
Copied
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?
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?
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/animate-discussions/assigning-props-functions-with-for-loop-vs-directly/m-p/282891#M277838
Jul 13, 2007
Jul 13, 2007
Copy link to clipboard
Copied
cayennecode,
> Of course that'd be silly if X number of objects was 100, or
> even 10...I'm lazy.
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.
> I'm simply curious as to what runtime performance difference
> there would be. Anyone tried anything like this, or care to
> speculate in theory?
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."
> Of course that'd be silly if X number of objects was 100, or
> even 10...I'm lazy.
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.
> I'm simply curious as to what runtime performance difference
> there would be. Anyone tried anything like this, or care to
> speculate in theory?
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."
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/animate-discussions/assigning-props-functions-with-for-loop-vs-directly/m-p/282892#M277839
Jul 13, 2007
Jul 13, 2007
Copy link to clipboard
Copied
>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.
HAH! I hear that!
>much is going on with the various assignments. If they're long/complex
>enough, a loop saves typing.
HAH! I hear that!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

