Problem with addChild()

Hi! I am trying to create a menu dynamically by using adding instances of a movie clip (a button) to the stage.

  1. First I create a movieclip named mcMainButtons.
  2. Then I have a loop that create instances of the buttons which are added to the mcMainButtons with the addChild function.
  3. At last I add the mcMainButtons to the stage with addChild.

My problem arises when I try to access the buttons. I have named them “btnHome”, “btnGallery” etc. (I have traced their names to see that this is correct), but when I try to access them, e.g. by writing trace(mcMainButtons.btnHome.x), I get an error telling me that “TypeError: Error #1010: A term is undefined and has no properties.”

If anybody could help me solve my problem, I would be really thankful:)

(here is the relevant code, just in case (colButtons_main is just an array with the button names))

function SetMainButtons() {
var i:int;
var strBtnName:String
mcMainButtons=new MovieClip;
mcMainButtons.name=“mcMainButtons”;

for (i=0; i<=colButtons_main.length-1; i++) {

var btnMainButton:mcTop_btn=new mcTop_btn;
btnMainButton.name=“btn”+colButtons_main*;
btnMainButton.txtName.text=colButtons_main*;
mcMainButtons.addChild(btnMainButton);
btnMainButton.x= //formula (irrelevant)
btnMainButton.y= 20

}
mcTop.addChild(mcMainButtons);
mcMainButtons.x=0
mcMainButtons.y=0
trace(mcMainButtons.btnHome.x)
}