# Help with dynamic buttons!

**URL:** <https://forum.kirupa.com/t/help-with-dynamic-buttons/220199>\
**Category:** flash\
**Created:** [March 23, 2007, 3:51pm UTC](https://forum.kirupa.com/t/help-with-dynamic-buttons/220199 "2007-03-23T15:51:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![brunosra](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@brunosra](https://forum.kirupa.com/u/brunosra)\
**Post date:** [March 23, 2007, 3:51pm UTC](https://forum.kirupa.com/t/help-with-dynamic-buttons/220199/1 "2007-03-23T15:51:44Z")

</div>

Hey, people!

I’ve got the following problem: I’m trying to generate a menu using attachmovie, and this menu will load several images. the idea is fine, lol.

But what is really happening is that, as I click on any button, it just use the last array value, instead of assigning one value to each button separately.  
The code below can illustrate this, but only with a trace. Where is my mistake?

Thanks a lot for the help.  
Here goes the code:

```auto

// create the pics array:
var fotos:Array = new Array();
fotos = ["01.jpg","02.jpg","03.jpg","04.jpg","05.jpg","06.jpg","07.jpg","cobra_gde.jpg"];
_root.transicoes.foto_antiga.loadMovie(fotos[0]);

//create pictures menu:
for (i=0;i<fotos.length;i++){
  botao_mc = attachMovie("button_mc","button"+i,_root.getNextHighestDepth());
  foto_atual = fotos*;
//buttons identifiers:
  if(i<9) {
    indice = i+1;
    botao_mc.legenda = "0"+indice;
  }else{
    indice = i+1;
    botao_mc.legenda = indice;
  }

//buttons position:
  botao_mc._x = 10;
  if(i == 0){
    botao_mc._y = 10;
  }else{
    botao_mc._y = 10 + (botao_mc._height*i) + 2;
  }

//button animation:
  botao_mc.onEnterFrame = function(){
    if(this.hitTest(_xmouse,_ymouse,true)){
      this.nextFrame();
    }else{
      this.prevFrame();
    }
  }
//button actions
  botao_mc.botao.onRelease = function(){
    trace(foto_atual);
  }
}

```
