How do i use a for loop to create instances?

I’m trying to parse an XML file, and use it to create instances of a custom class
the fly in actionscript 2. (can’t migrate to 3 for this project).

I’m trying to make something happen like:


for (var i:Number=0; var<n; var++) {
    instanceName="MyObject"+i;
    var instanceName:MyObject = new MyObject(property, property, property);
    instanceName.method(blah, blah, blah);
}

Which doesn’t work, but hopefully you get the idea…

When it’s all done, I need to have n objects named MyObject1, MyObject2, …, MyObject(n).

How do I do that?