Moderator: Paul Tuersley

Topic Author
Posts: 13
Joined: Tue Jan 05, 2010 1:37 am

Dropdown Menu listing all layers in active comp

Sat Feb 26, 2011 12:49 pm


This request seems simple but I haven't seen an example of what I am looking for anywhere. I have a UI where I want to create a dropdown box listing all the layers in the comp. I think I know how to get the dropdown created, but I am not sure how to generate an array of all the layer names.
Paul Tuersley
Posts: 704
Joined: Sat Jun 05, 2004 7:59 am
Location: London, UK

Re: Dropdown Menu listing all layers in active comp

Fri Mar 04, 2011 3:55 am

Here's some code that won't work on its own, but should give you some ideas. The layerNameArray stuff shows how you could create an array of layer names. The palette stuff shows how you might implement adding items to a drop down. I imagine that this is something that will need refreshing, so you could first do a removeAll to clear out the list, then loop through the layers adding a new list item for each name.

   var activeItem = app.project.activeItem;   
   if (activeItem != null && activeItem instanceof CompItem) {
      var layerNameArray = new Array();   
      for (var x = 1; x <= activeItem.numLayers; x++) {
         palette.dropDown.add("item", activeItem.layer(x).name);

Who is online

Users browsing this forum: No registered users and 3 guests