Posts Tagged iterate

Iterating Multiple Lists In Order: Part 2

Tags: , ,

Last week I presented a problem: how do you iterate over multiple lists of multiple types in the order of some common field? For example, how would you iterate over a list of Player and a list of Enemy by both of their Health fields? In that article I showed two solutions to iterate over two lists in this way. What I didn’t show were any solutions to handle more than two lists. What if you needed to also iterate over a list of NPC? Today’s article discusses how to tackle this problem and ends up with a handy utility class that you can use for your own types no matter how many lists you have. Read on to see how!

Read the rest of this article »

No Comments

Utility Function: getProperties

Tags: , , , , , , , , ,

Quite often I have wanted to iterate over the public fields (and getters) of an arbitrary object. Sometimes this is for debugging purposes so I can print out the state of an object, particularly one that has all public fields like a C/C++ structure. Sadly, this is not possibly (with most objects) using the for-in and for-each loops we’ve come to know and love. So I made a utility function that I’m sharing with you all today. UPDATE: getProperties now supports MovieClip derivatives such as library symbols from an FLA

Read the rest of this article »

8 Comments