Copy link to clipboard
Copied
Hello,
I want an alert prompt if there are no layers selected.
I have this to set up my variables.
//set variables
myProj = app.project;
myComp = myProj.activeItem;
myLayer = myComp.selectedLayers[0];
//my code
if (myLayer === undefined){
alert ("Select a Layer);
}
Ive tried myLayer == 0, and myLayer == null;
Any help is appreciated. Thanks!
Copy link to clipboard
Copied
i have end quotes on the alert above. Just a typo here
Copy link to clipboard
Copied
Layer selections are arrays. You have to query the size of the array with myLayers.length, not the contents of the collection.
Mylenium
Copy link to clipboard
Copied
var myProj = app.project;
var myComp = myProj.activeItem;
if(!(myComp instaneof CompItem)) alert("please select a layer (active item is not a composition)");
else {
if(myComp.selectedLayers.length ==0) alert("please select a layer (a comp is active, but there is no layer selected in this active comp)");
}
(I didn't check the code, it might contain typos)