Assign variables do dynamic created buttons?

Hi:

I have a 13 buttons to wich I added Event listeners using a for loop:

for (var i:Number = 1; i < 13; i++)
{
        this["main_bt_" + i].addEventListener(MouseEvent.CLICK, onClick);
}

function onClick(e:MouseEvent):void
{
    trace(i);
}

When clicking the button it should return the variable i that generated it (1,2,3…etc)

It always returns the last i (13).

How can I get this to work? Do I have to create the buttons manually and add a functions to each button?

Thanks!