# Storing values using loop

**URL:** <https://forum.kirupa.com/t/storing-values-using-loop/257908>\
**Category:** flash\
**Created:** [April 18, 2008, 8:44am UTC](https://forum.kirupa.com/t/storing-values-using-loop/257908 "2008-04-18T08:44:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![black\_pearl](https://avatars.discourse-cdn.com/v4/letter/b/aeb1de/32.png) [@black\_pearl](https://forum.kirupa.com/u/black_pearl)\
**Post date:** [April 18, 2008, 8:44am UTC](https://forum.kirupa.com/t/storing-values-using-loop/257908/1 "2008-04-18T08:44:09Z")

</div>

I have five buttons on stage and I simply want to trace “1” when I click the first button and trace “2” when I click the second button and so on.

Here is the code

```auto
var buttonsArray:Array = new Array('sil_btn', 'sfl_btn', 'srl_btn', 'srf_btn', 'shpl_btn')
for(var i:Number = 0; i< buttonsArray.length; i++)
{
i = pressed;
this[buttonsArray*].onRelease = function()
{
    trace("buttonNumber"+i)
}
}

```

I am always getting the last number and cannot figure out, how to store the values.
