Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

assigning props/functions with for loop vs directly

Guest
Jul 13, 2007 Jul 13, 2007
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?
TOPICS
ActionScript
217
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 13, 2007 Jul 13, 2007
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."


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 13, 2007 Jul 13, 2007
LATEST
>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!


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines