Dynamic Button Functions

Hi, I’m trying to dynamically set the text for captions that get triggered on a button rollover.

Currently I have, thanks to the kirupa tutorial…


b1.onRollOver = function() { 
	captionFN(true, "text for the caption", this); 
	this.onRollOut = function() { 
	 captionFN(false); 
	}; 
};

but I have about fifty buttons, i.e b1, b2 ,b3 ,… . b50 and the caption text is read from an xml file so I could just copy and paste that 50 times but would much prefer to be able to have it a small for loop.

So what I would thought might work for my problem was:


for (var i:Number=0; i < 50; i++) {
	root["b" + i].onRollOver = function() {
		captionFN(true, arrPlotText*, this); 
		this.onRollOut = function() { 
			 captionFN(false); 
		 }; 
	};
}

where the buttons are on _root and the array -> arrPlotText is already filled with the text needed, but it doesnt work.

cheers to anyone who can help.
stibos