# Numbers of dynamically created buttons

**URL:** <https://forum.kirupa.com/t/numbers-of-dynamically-created-buttons/249268>\
**Category:** flash\
**Created:** [January 17, 2008, 1:43am UTC](https://forum.kirupa.com/t/numbers-of-dynamically-created-buttons/249268 "2008-01-17T01:43:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian914](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@brian914](https://forum.kirupa.com/u/brian914)\
**Post date:** [January 17, 2008, 1:43am UTC](https://forum.kirupa.com/t/numbers-of-dynamically-created-buttons/249268/1 "2008-01-17T01:43:41Z")

</div>

I have started to create my buttons dynamically. When doing so, I would like to have a number for each, that I can use to then call other things, such as text from an array, images, etc. All my assets in this file are numbered. For example, the button that I am creating with the following for loop, will have a string from an array, and a jpg that will load when it is clicked.

This is how I am creating the buttons.

for(var i:Number = 0; i \< thumbs; i++){  
var ref:MovieClip = thumb\_scroller.all\_thumbs[“thumb” + i];  
ref.onRelease = function():Void {  
clickAction();  
}  
};

For example, “thumb\_scroller.all\_thumbs.thumb5” will, when clicked, load a jpg, called 5.jpg and reference a string from an array, at the 5 place in that array. So, if I could somehow, send the number 5 as a parameter with the clickAction();, I could then do what I want. I had tried something like this clickAction(i); but it did now work, because i got updated until the for loop was done and so had the same value for all buttons created by it. How is this done? Is there a way to create dynamic variable that I can send as a parameter with the clickAction()?

Thanks a lot. Any help would be greatly appreciated!!!
