# Using for loop to add code to mc's

**URL:** https://forum.kirupa.com/t/using-for-loop-to-add-code-to-mcs/293927
**Category:** Uncategorized
**Created:** [August 5, 2009, 10:27pm UTC](https://forum.kirupa.com/t/using-for-loop-to-add-code-to-mcs/293927 "2009-08-05T22:27:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ricmetal](https://avatars.discourse-cdn.com/v4/letter/r/b782af/32.png) [@ricmetal](https://forum.kirupa.com/u/ricmetal)
#### Post date: [August 5, 2009, 10:27pm UTC](https://forum.kirupa.com/t/using-for-loop-to-add-code-to-mcs/293927/1 "2009-08-05T22:27:38Z")

</div>

doesnt work  
i would expect this to work  
well it does work, just not how its intended to

```auto

for(i=1; i<=3; i++) {
    _root["btn"+i].onRelease = function() {
        trace("line"+i);
    }
}

```

each button traces “line4”

anybody know why?
