FORUMS: list search recent posts

Extendscript - Dropdownlist on change and retrieving Compositions

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Benoit Kergosien
Extendscript - Dropdownlist on change and retrieving Compositions
on Mar 29, 2015 at 7:03:30 pm

Hi folks!

I'm trying to create a script based on two dropdownlists:

the first can access to all the comps of the project
the second access to specific layers of the comp selected previously with the first dropdownlist.

I stored the comp's names in an array and apply them in my first dropdown list.
But I can't set up a way to specify the comp selected in the dropdownlist to access to its layers.


Do I have to used names, index, item id and how to do this?

So far my code is the following (including errors):

==========

// detect the language
var utils = this;
this.loc = function (str)
{
var lang = parseFloat(app.version) < 9 ? $.locale : app.isoLanguage;
return lang.toLowerCase().match("fr") ? str.fr : str.en;
};

// store Compositions
function grabAllComps(){
var proj, itemTotal, curItem, itemAry
itemAry = new Array();
proj = app.project;
itemTotal = proj.numItems;
for(var i=1; i<=itemTotal; i++){
curItem=proj.item(i);
if(curItem instanceof CompItem){
itemAry[itemAry.length] = curItem.name;
}
}
return itemAry
}
// store specific Layers of the Compositon selected in the dropdownlist

var ddlCompSelected = dropComp.onChange();
var layers = ddlCompSelected.layers;
var matchingLayers = new Array();
var layer;
function grabSpecificLayers(){
for (var i = 1; i <= layers.length; i++)
{
layer = layers[i];

if (!(layer instanceof ShapeLayer) && !(layer instanceof CameraLayer) && !(layer instanceof LightLayer) && !(layer.adjustmentLayer) && !(layer instanceof TextLayer) && !(layer.nullLayer))
{
matchingLayers[matchingLayers.length] = layer.index +" : " + layer.name;
}
}
return matchingLayers
}


// Steps Text
this.firstStep = {en:"Select a comp",fr:"Sélectionner une composition"};
this.secondStep = {en:"Select a layer",fr:"Sélectionner un calque"};

// BUILD UI
var myWin = new Window("palette","",undefined);
myWin.orientation = "row";
var panelOne = myWin.add("panel", undefined,"dropdownlist test");
panelOne.add("statictext",undefined,utils.loc(this.firstStep));
var dropComp = panelOne.add("dropdownlist",[0,0,200,20],grabAllComps());
//dropComp.selection=1;
dropComp.onChange = function () {
this.selection.text;
}
panelOne.add("statictext",undefined,utils.loc(this.secondStep));
var dropLayer = panelOne.add("dropdownlist",[0,0,200,20],grabSpecificLayers());
dropLayer.selection=1;

myWin.center();
myWin.show();

==========

Thanks for your help.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]