The code below works fine to make a red ball from my library dance around screen. But I want to have a hundred balls doing the same thing. In the old days I'd use the eval command with duplicatemovieclip and now it's the square brackets but .... var container1 = new RedBall(); this line works,
var this["container"+n] = new RedBall(); - THIS DOESN'T!!!
But if you look at the code below. Once the variable has been created in line 3 I can refer to it dynamically. But I need to 'create' it dynamically too. Anyone help, going mental??? Big Thanks.
JAB

To use the code below simply put a symbol called RedBall into your library.


var n = 1;
var jjj = new YellowContainer();
var container1 = new RedBall();// THIS LINE WORKS FINE BUT IS NOT DYNAMIC, I WANT TO USE THE ONE BELOW.
// var this["container"+n] = new RedBall(); // THIS LINE SHOULD WORK BUT DOESN'T WHICH IS ANNOYING ME......
this["container"+n].x = 200;//BUT I CAN START USING THE DYNAMIC VARIABLE LIKE THIS ONCE IT'S FIRST CALLED IN THE 3RD LINE (var container1 = new RedBall()
this["container"+n].y = 100;
this.addChild(this["container"+n]);
container1.addEventListener(Event.ENTER_FRAME, themain);
function themain(event:Event):void {
this["container"+n].x = Math.random()*200.0;
}