-
increments for loop
Hopefully someone might be able to suggest something.
I have an array that create buttons, but I want to create a new row for every so many buttons. I’ve looked at resize(), but it’s going over my head. Currently…I manually say for 1-5 create row1, 6-10 create row2
I want to simplify it in a for loop. I know the below code isn’t right, but hopefully suggests what I want
for(var i=1, i
currently it looks like this, but I just want to make it look neater, plus if I add more to the array I don’t have to create a new row every time.
var b = new Array();
for(var i = 0; i <= 44; i++ ){
var f = File (file.name)
if(i <= 6){
b[i] = buttonsRow1a.add (“iconbutton”, undefined, f, {style: “toolbutton”});
}else if(i >= 7 && i <= 13){
b[i] = buttonsRow1b.add (“iconbutton”, undefined, f, {style: “toolbutton”});
}else if (i >= 14 && i <= 20){
b[i] = buttonsRow1c.add (“iconbutton”, undefined, f, {style: “toolbutton”});
}else if(i >= 21 && i <= 27){
b[i] = buttonsRow1d.add (“iconbutton”, undefined, f, {style: “toolbutton”});
}else if(i >= 28 && i <= 34){
b[i] = buttonsRow1e.add (“iconbutton”, undefined, f, {style: “toolbutton”});
}else if(i >= 35 && i <= 41){
b[i] = buttonsRow1f.add (“iconbutton”, undefined, f, {style: “toolbutton”});
}else{
b[i] = buttonsRow1g.add (“iconbutton”, undefined, f, {style: “toolbutton”});}
}