# Dynamic Button Problem

**URL:** https://forum.kirupa.com/t/dynamic-button-problem/148033
**Category:** Uncategorized
**Created:** [May 16, 2005, 5:43pm UTC](https://forum.kirupa.com/t/dynamic-button-problem/148033 "2005-05-16T17:43:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![amsams](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@amsams](https://forum.kirupa.com/u/amsams)
#### Post date: [May 16, 2005, 5:43pm UTC](https://forum.kirupa.com/t/dynamic-button-problem/148033/1 "2005-05-16T17:43:30Z")

</div>

Someone pls help me,

I’m creating a dynamic button with the attach movie method, here’s the code

```php
 onClipEvent (load){
thumbnail = 4; 
for (i=1;i<=thumbnail;i++){
attachMovie("thumbnail_button", "thumbnail_button"+i, i);
this["thumbnail_button"+i]._y = 0;
this["thumbnail_button"+i]._x = (i-1)*110;
trace(i);
this["thumbnail_button"+i].onRelease = function(){
trace ("button number: " + i + " has been pressed"); 
}
}
}

```

It loads the 4 thumbnials correctly, but the buttons all trace the same string, what i mean is all four buttons will trace:

“button number: 5 has been pressed”

instead of:

“button number: 1 has been pressed”  
“button number: 2 has been pressed” etc

Can’t seem to figure out what i did wrong, Pls help. Thanks in advance
