I think I’ve copied and pasted all that you need.
Essentially, I create an array of colours I want, then create all my buttons using the fillBrush. Then use the array to array through my buttons to match the same colour of the array.
Hopefully the below makes sense, because I still struggle to understand it with the Array bouncing out of other arrays, it took a few days of attempting this for me to get it to work.
var pcolor = new Array([0/255,68/255,137/255,255/255],[255/255,255/255,255/255,255/255])
var b = new Array();
for(var i = 0; i <= 1 ; i++ ){
b[i] = groupOne.add (‘iconbutton’, undefined, undefined, {name:’Blue’, style: ‘toolbutton’});
b[i].size = [30,20];
b[i].fillBrush = b[i].graphics.newBrush(b[i].graphics.BrushType.SOLID_COLOR,pcolor[i]);
b[i].onDraw = customDraw;
function customDraw()
{ with( this ) {
graphics.drawOSControl();
graphics.rectPath(0,0,size[0],size[1]);
graphics.fillPath(fillBrush);
if( text ) graphics.drawString(text,textPen,(size[0]-graphics.measureString (text,graphics.font,size[0])[0])/2,3,graphics.font);
}}
}
for(var i = 0; i <= 1 ; i++ ){
b[i].onClick =
(function(i){
return function() {
app.beginUndoGroup(“AddEffect”);
var curItem = app.project.activeItem;
var selectedLayers = curItem.selectedLayers;
for (var j = 0; j < selectedLayers.length; j++) {
try {
curRem = selectedLayers[j].effect.property(“Fill”).remove();
curLayer = selectedLayers[j].Effects.addProperty(“ADBE Fill”)(“Color”).setValue(pcolor[i]);
}
catch (err) {
curLayer = selectedLayers[j].Effects.addProperty(“ADBE Fill”)(“Color”).setValue(pcolor[i]);
}
}
app.endUndoGroup();
}
})(i);
}