Copy link to clipboard
Copied
Hi,
This is my second post about the Listbox script. I am new here, so please bear me more. In the first post justintaylor help me a lot and I am very grateful to him and all the professionals in the community for their support. I ask the professionals to develop and correct my script to learn more from you.
(function(){
$.win = new Window("palette");
var win = $.win;
win.text = "Link";
win.orientation = "column";
win.alignChildren = ["center", "top"];
win.spacing = 10;
win.margins = 16;
var listbox1 = win.add("listbox", undefined, undefined, { name: "listbox1", multiselect: true, columnTitles: "Max", showHeaders: true });
listbox1.preferredSize.width = 136;
listbox1.preferredSize.height = 208;
var button1 = win.add("button", undefined, undefined, { name: "button1" });
button1.text = "Search";
var button2 = win.add("button", undefined, undefined, { name: "button2" });
button2.text = "Delete";
win.show();
var myNewArray = [];
button1.onClick = function Search() {
var compsArray = new Array();
var myProj = app.project;
myNewArray = [];
listbox1.removeAll();
for (var i = 1; i <= myProj.numItems; i++) {
if (myProj.item(i) instanceof CompItem) {
myNewArray = compsArray[compsArray.length] = myProj.item(i);
listbox1.add("item", myNewArray.name);
}
}
}
button2.onClick = function deletecomps() {
if (listbox1.selection.text = myNewArray.name) {
myNewArray.remove();
}
}
})();
This a screenshot of the script in AE.
What is it you are trying to achieve with this code? It's not quite clear.
In case you need to select list box items and remove then from the list along with compositions from project panel, here's a working snippet
button1.onClick = function Search() {
listbox1.removeAll();
for (var i = 1; i <= app.project.numItems; i++) {
var projectItem = app.project.item(i);
if (projectItem instanceof CompItem) {
var listboxItem = listbox1.add("item", projectItem.name);
listboxItem.id = project
...
Copy link to clipboard
Copied
Your if statement is broken. You need to use double or triple quotes:
if (listbox1.selection.text = myNewArray.name) {
Copy link to clipboard
Copied
It is not working.
Copy link to clipboard
Copied
I am very greatful for your time and effort Tomas_Sinkunas 😉
Copy link to clipboard
Copied
What is it you are trying to achieve with this code? It's not quite clear.
In case you need to select list box items and remove then from the list along with compositions from project panel, here's a working snippet
button1.onClick = function Search() {
listbox1.removeAll();
for (var i = 1; i <= app.project.numItems; i++) {
var projectItem = app.project.item(i);
if (projectItem instanceof CompItem) {
var listboxItem = listbox1.add("item", projectItem.name);
listboxItem.id = projectItem.id;
}
}
};
button2.onClick = function deletecomps() {
for (var i = listbox1.selection.length - 1; i >= 0; i--) {
var listboxItem = listbox1.selection[i];
var composition = app.project.itemByID(listboxItem.id);
if (composition) {
listboxItem.parent.remove(listboxItem);
composition.remove();
}
}
};
Copy link to clipboard
Copied
Thanks for gods of coding
It is working ;-))))))))
I am really a novice and using it for my personal use...
Find more inspiration, events, and resources on the new Adobe Community
Explore Now