# Buttons created in a loop

**URL:** https://forum.kirupa.com/t/buttons-created-in-a-loop/241937
**Category:** Uncategorized
**Created:** [October 19, 2007, 4:59pm UTC](https://forum.kirupa.com/t/buttons-created-in-a-loop/241937 "2007-10-19T16:59:44Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tarafenton](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/tarafenton/32/652_2.png) [@tarafenton](https://forum.kirupa.com/u/tarafenton)
#### Post date: [October 19, 2007, 4:59pm UTC](https://forum.kirupa.com/t/buttons-created-in-a-loop/241937/1 "2007-10-19T16:59:44Z")

</div>

Hi

I am using a for loop to create text to use as buttons. Which works fine. The problem is when I rollover them it is not calling the correct ID. I had a work around for it in AS2.

```auto

    var name:String = "titleButton"+i;
        _level3["titleButton"+i].ID = i;
        //ROLLOVER FUNCTION FOR SECOND NAVIGATION
        _level3[name].onRollOver = function() {

```

I am trying to trace out the correct ID in AS3

```auto
var name:String = "issueNumber_tf"+i;
        var ID:int = i;
                issueNumber_tf.addEventListener(MouseEvent.MOUSE_OVER, listenerFunction);

        function listenerFunction(evt:MouseEvent):void {
           
            trace("PLEASE CHANGE "+this.ID);

```

But I am getting different errors and need a little guidance.  
Please any suggestions would be helpful

Thanks  
Tara
