Dynamically placing new buttons

Hello,

It’s been a few years since I’ve last used ActionScript, so I’m a bit rusty :stuck_out_tongue: Anyways, I have 16 buttons in my library with linkage names btn0-btn15. I can successfully add them onto the stage by saying something like:

var tempBtn:SimpleButton = new btn0();
stage.addChild(tempBtn);

I’m going to be tinkering with the buttons layout and positions, and I would like to add each of the different buttons to the stage dynamically with a for loop. I’ve been trying different variations of this:

for (int i:int=0; i<16; i++) {
    var tempBtn:SimpleButton = new ["btn" + i]();
}

but I just can’t seem to find the right syntax for doing this correctly. Any suggestions? :slight_smile: