# Problem with btn inside an attached MC

**URL:** <https://forum.kirupa.com/t/problem-with-btn-inside-an-attached-mc/166306>\
**Category:** flash\
**Created:** [October 18, 2005, 8:16pm UTC](https://forum.kirupa.com/t/problem-with-btn-inside-an-attached-mc/166306 "2005-10-18T20:16:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gloqui](https://avatars.discourse-cdn.com/v4/letter/g/97f17d/32.png) [@gloqui](https://forum.kirupa.com/u/gloqui)\
**Post date:** [October 18, 2005, 8:16pm UTC](https://forum.kirupa.com/t/problem-with-btn-inside-an-attached-mc/166306/1 "2005-10-18T20:16:47Z")

</div>

Hi!

I have a problem with an attached MC that I have but I can’t figure out how to handle it.

Here’s the deal, I have a MC with some dynamic text, a mc container and button.  
The swf attachs as many MC says a variable that is on an .txt file.

Everything works ok, except, the part of the button. Here I attach part of the code so you can understand me:

i = 0  
while (i \<= (\_root.variables.cantidad)) {  
i++;  
this.attachMovie(“cuadro”,“cuadro”+i,i)  
setProperty(this[“cuadro”+i],\_y,40\*i - 40);  
loadMovie(“viejos/pequenas/img” add i add “.jpg”,this[“cuadro”+i].imagen);  
this[“cuadro”+i].marca.text = \_root.variables[“marca”+i]  
this[“cuadro”+i].equipo.text = \_root.variables[“equipo”+i]  
this[“cuadro”+i].referencia.text = \_root.variables[“referencia”+i]  
this[“cuadro”+i].yearr.text = \_root.variables[“yearr”+i]  
this[“cuadro”+i].img.text = \_root.variables[“img”+i]  
\_root[“ulr”+i] = “javascript:openWindow(’” add “viejos/img” add i add “.htm’,” add “‘myNewWindow’, ‘toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500,height=350,left=40,top=90’)”  
this[“cuadro”+i].btn.onRelease = function () {  
trace(\_root[“ulr”+i])  
}  
}

When I click any of the buttons it always open the img10.htm (if I put for example on the .txt 10 as the required MC to attach, which is in the \_root.variables.cantidad in the AS above). I need that each button opens img1.htm, the other img2.htm and so on, but it doesn’t work. I can’t figure out why if the rest of the elements (dynamic texts and images loaded) works ok.

Please somebody help me with this, I don’t know what I’m doing wrong.
