How to target dynamically created objects

[SIZE=1]Hi, I am learning AS3, and I am trying to understand how to target dynamically created objects. I have the code:

for (var i:Number = 0; i<5; i++) {
    var boton:CreateButton(stage.stageWidth/5,30,0,1,colors*,test,0xFFFFFF,"English");"button"+i;

and I created this to target the buttons. I don’t know if this is the way to do it:


[SIZE=1]var button0:* =getChildByName('button0');
var button1:* =getChildByName('button1');
var button2:* =getChildByName('button2');
var button3:* =getChildByName('button3');
var button4:* =getChildByName('button4');


Could you please share some advice