# Attach MC + how to code so it counts up

**URL:** <https://forum.kirupa.com/t/attach-mc-how-to-code-so-it-counts-up/175318>\
**Category:** Uncategorized\
**Created:** [January 13, 2006, 11:54am UTC](https://forum.kirupa.com/t/attach-mc-how-to-code-so-it-counts-up/175318 "2006-01-13T11:54:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tristessa](https://avatars.discourse-cdn.com/v4/letter/t/a88e4f/32.png) [@tristessa](https://forum.kirupa.com/u/tristessa)\
**Post date:** [January 13, 2006, 11:54am UTC](https://forum.kirupa.com/t/attach-mc-how-to-code-so-it-counts-up/175318/1 "2006-01-13T11:54:18Z")

</div>

Hello there. I am trying to build a menu from nul.

The idea is that i have one mc on the stage (design purposes) and when clicked it generates a bunch of copys,  
now later i want to attach some extra code to each generated button/mc.

does one have a guideline for this?  
so that standard\_mc becomes after its been generated get’s for example standard\_mc01, 02,03.

I use this simple code to generate them.

```auto

//create root button
this.createEmptyMovieClip("canvas_mc", 1);
ref1 = this.attachMovie("button", "ref1" + i, 100 + i);
ref1._level = 100;
ref1.vALUE = "_root";
ref1._x = 10;
ref1._y = ref1._x;
//ref1._level = 100;
trace ("root has been build"+ _level);

buildmenu = function (){
for (i = 0; i < 4; i++) {
    buttons = this.attachMovie("button", "buttons" + i, 90 + i);
    //position each button on stage. 
    gutter = 111;
    place4buttons = i * 101 + gutter;
    buttons._x = buttons.tween("_x", place4buttons, 0.9, customEasing);
    buttons._y = 10;
    buttons.vALUE = "generated";
    buttons.onRelease = function(){
    trace ("klicked button" + buttons.getDepth());
        }
    }
}
ref1.onRelease = function(){
    trace ("build sub");
    buildmenu();
}

```

this works like a charm only i stumble on these problems.

a) how to i make sure the generated copies are UNDER my main button, i am aware of the levels but it keeps gerenating above the main button(ref1)  
b) how do i make sure that i can assign each generated button later with some individual actionscript.and change some text values easy.

i found out all this by myself, but I feel stuck right now, code is stilla bit sloppy due to experimenting 😉  
Thanks bigtime if someone can assist me.
