views:

32

answers:

1

Hi

I am loading my menu items from an XML file for dynamism, but I am not sure what to do about the following, should I populate an array with the items and then use the array for reference in creating the movieclips later, or should I rather immediately create the movieclips and populate them with the data received from the XML file without leaving a trail?

The benefits are bit equal, it seems to me.

A: 

I can think of two possible reasons to make an intermediate array:

  1. If there may be cases where you aren't ready to create the menu immediately when the XML loads (because, for example, you're loading other assets or displaying an animation). It's clean and straightforward to process the XML immediately when it finishes loading, so the XML object can be released, so if you're not ready to make the menu yet it would make sense to parse it into an intermediate array.
  2. If you feel the XML format or handling are complex enough that parsing into an intermediate array might make the code more readable to any future maintainers (including yourself).

If neither case is present, I don't see any need for an intermediate step.

fenomas