My interest is in creating a row buttons that are dynamically generated and placed as determined by xml content (number of buttons that is). The buttons are multiple instances of the same clip (attached) that contain textfields which display numbers (ie. 01, 02, …20). The number of buttons generated shall be capped to a max of 20.
I have parts of it figured out and need help with others. The generation of the clips are handled by the following loop…
// Starting x & y values
var xPos:Number = 150;
var yPos:Number = 400;
// Maximum number of buttons allowed
var btnMax:Number = 20;
for (i = 0; i < gallery.length; i++) {
attachMovie("btn_mc", "btn"+i, this.getNextHighestDepth(), {_x:xPos, _y:yPos});
xPos += this["btn"+i]._width+5;
// Add the information
this["btn"+i].num.text = ?
The numbers on the buttons start with 01 and go up to 20. I am familiar with the method of concatinating “0” + i for the first 9 digits in the loop but then how do you account for the shift from “0” to “1” as the first digit in these two digit numbers? Know what I mean?
I do understand that in instances like this you can create an array where each of the number values are declared but that’s not what I’m after here. I’d like to know what concatination methods are used in instances like this where the first number changes as well as the second number in double-digit numbers. I hope this makes sense.
Lastly, how would you approach creating rollover states for the text in the textfields of these dynamically generated buttons that have the numbers change color on rollover?
Three questions in a nutshell:
- how do you cap the btnMax to 20 buttons?
- how do you pass the correct numbers to the dynamic textfields without referencing an array directly for each of the values?
- how do you create rollover states for the numbers?
Why “for smart people”? Because you are a smart person to have these answers. TIA.