I want to change buttons.
I can change the text or shape. But I can't seem to add or remove a button. I'm reading a json/ase file. That creates buttons based on the name I define. This works fine on opening the app. However should I want to change it "if(colorData.name.indexOf(btn.text) > -1)"
var btnGrp = this.win.add('group', undefined, undefined, {alignment: 'fill'});
var btn = btnGrp.add('edittext', undefined, "DA ");
var apply = btnGrp.add('button', undefined, 'APPLY');
var aseFile = File("/Volumes/Server/Media/Brands/CA Brand Colours new.ase");
var data = app.parseSwatchFile(aseFile);
var numColors = data.values.length;
//Create Array from aseFile
var dataField = new Array();
for (var i=0; i<numColors; i++){ var colorData = data.values[i];
if(colorData.type == "RGB"){
if(colorData.name.indexOf(btn.text) > -1){
color = [colorData.r, colorData.g, colorData.b, 1];
dataField[dataField.length] = new Array(color,colorData.name); }
}
}
var b = new Array();
for(var i = 0; i < dataField.length ; i++ ){
b[i] = btnGrp.add('iconbutton', undefined, undefined, {name:'Blue', style: 'toolbutton'}); b[i].size = [30,this.defaultSize[1]];
b[i].fillBrush = b[i].graphics.newBrush(b[i].graphics.BrushType.SOLID_COLOR,dataField[i][0]);
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); }
}
}
apply.onClick = function(){
btn.text = "CAI ";
CHANGE MY BUTTON ARRAY;
};


Any ideas?