javascript - ExtendScript get index number from searched Comp result -


i've got code sorting through various items in after effects , returning compositions in project, narrow down based on specific composition i'm looking for, in case 1 ending assemble. name , that's great need index number come along name, when search assemble return of app.project.item(3), index in project window. every time try number array seem total number of items doesn't help.

thanks.

function retrieveprojectitems(itemtype){ var typeoptions = ["composition", "folder", "footage"]; for(var t = 0; t<3; t++){     if(itemtype == typeoptions[t]){         var proj, itemtotal, curitem, itemarray;         itemary = [];         proj = app.project;         itemtotal = proj.numitems;         for(var = 1; <= itemtotal; i++){             curitem = proj.item(i);              //alert(curitem.name);               if(curitem.typename == itemtype){                 itemary[itemary.length] = curitem.name;                 }             }         return itemary;          }     } } retrieveprojectitems("composition"); //alert(comps); lists comps in array  var comps = itemary; var compwithassemble; for(var in comps){ if(comps[i].indexof("assemble") > -1){ ///search part of name///////////////////////////////////     compwithassemble = comps[i];      break; } } // compwithassemble has string looking for. alert(compwithassemble); //app.project.item(3).selected = true; compwithassemble.selected = true; //i'm looking make work... 

i assuming want programatically find composition layer named "assemble"

this bit of code

if(comps[i].indexof("assemble") > -1){ ///search part of name///////////////////////////////////     compwithassemble = comps[i];      break; } 

does not give results want because comps[i] object of compitem, not array or collection. need first retrieve layer collection each comp[i]. then, when have layercollection, can find layer named "assemble" using .byname() method. if don't returned layer, you'll receive null, otherwise, you'll receive layer object.

it might like:

var comps = itemary; var compwithassemble;  (var in comps){     if(comps[i].layers.byname("assemble") != null) {        compwithassemble = comps[i];        break;     } } 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -