# Dynamic buttons and their content

**URL:** https://forum.kirupa.com/t/dynamic-buttons-and-their-content/287490
**Category:** flash
**Created:** [May 1, 2009, 11:34pm UTC](https://forum.kirupa.com/t/dynamic-buttons-and-their-content/287490 "2009-05-01T23:34:53Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Freddythunder](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@Freddythunder](https://forum.kirupa.com/u/Freddythunder)
#### Post date: [May 1, 2009, 11:34pm UTC](https://forum.kirupa.com/t/dynamic-buttons-and-their-content/287490/1 "2009-05-01T23:34:53Z")

</div>

Hi,

I have a solution for this already, but it involves a million if/else statements so I was wondering if there’s a way around this. Here we go.

I’m making an RSS reader that displays posts in Craigslist. All the info I need is loaded into flash and immediately tossed into arrays. Well take the links[] array for our example.

I count the amount of links  
for(i=0;i\<links.length;i++){  
and I make my boxes to hold the info  
\_root.createEmptyMovieClip(“clbutton”+i,this.getNextHighestDepth());  
\_root[“clbutton”+i].createTextBox(“cltext”,10,10,10,10);  
\_root[“clbutton”+i].cltext.text = links\*;  
}

All of that (plus a whole lot more) works fine. Here’s the thing. I want an onRelease!

\_root[“clbutton”+i].onRelease = function(){  
trace(i);  
}

No matter what button (of the 25) I hit, it traces 25.

All I need is each button to remember it’s number for further processing. Can it be done? Is it simple? Is it hard? Am I dumb? _or smart?_

My work around is:  
\_root[“clbutton”+i].onRelease = function(){  
if(i==0){  
trace(0);  
}  
if(i==1){  
trace(1);  
}  
}
