I'm working on a script that finds a folder in my project named "compsRENDER" and then creates checkboxes for each comp and sets the text to the comp name - which works. I'm not sure how to handle the .onClick() so that each checkbox item specifically represents the corresponding comp. If I click on the checkbox: "comp1" it will send "comp1" to the renderQueue, for example.
Comps: "comp1", "comp2", "comp3", "comp4", etc...
Checkboxes: "comp1", "comp2", "comp3", "comp4", etc...
The script below currently works as follows: Finds all comps in the compsRENDER folder, adds checkboxes with each comps name. When I click on any checkbox it references the last comp instead of the corresponding comp - I'm assuming because of the loop that adds the checkboxes.
#include "/GFXM1/Script_Workflows/commonFunctions.jsx"
myWindow = new Window("palette", "My window name", undefined, {resizeable: true});
checkboxPanel = myWindow.add('panel');
var compNamesArray = new Array();
var renderFolder = locateProjItems(FolderItem, "compsRENDER"); //Use CompItem for comps
//Create checkboxes
for(i = 0; i < renderFolder.numItems; i++){
var currentCheckbox = checkboxPanel.add('checkbox');
currentCheckbox.text = renderFolder.items[i+1].name;
currentCheckbox.onClick = function(){ sendCompToRQ(currentCheckbox.text); }
}
function sendCompToRQ(checkboxName){
alert(checkboxName);
for(c = 0; c < renderFolder.numItems; c++){
if(checkboxName == renderFolder.items[c+1].name){
app.project.renderQueue.items.add(renderFolder.items[c+1]); // ADD: Comp to RQ
}
}
}
myWindow.show();