Dynamic buttons and their content

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);
}
}