I am attempting to create an animation from a sprite sheet.
I have a list of rectangles like this ...
public static var HappyBirthDay0001:Rectangle = new Rectangle(340,0,340,382);
The solution requires making an array of rectangles something like this:
happyBirthDayRects = [R.HappyBirthDay0001, R.HappyBirthDay0002, R.HappyBirthDay0003, R.HappyBirthDay0004 .....
Which seems inelegant.
Can I create this array on the fly with a loop? Can you help?
I want to do something like this... which obviously isn't code ...
for (var i:int = 0; i < 60; i++)
happyBirthDayRects.push("R.HappyBirthDay000" + i);
And yes it is a birthday card that has got out of hand.
Thank you very much for any advice
Hmm, well I would contend the first option is much better (but that's coming from someone who prefer's strongly typed languages).
I'm not sure if what you're trying to do works with static variables, since I've never actually tried it, but if it did work, it would look something like this...
Although you would need to add some logic to buffer the zeros correctly for any number larger than 9, which IMHO, is not an elegant solution at all. I actually think this would require more typing than the first solution (if you take autocompletion and copy/paste into account), not to mention the loss of type saftey.