ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

extendscript: onClick add n sliders

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Peter Zeet
extendscript: onClick add n sliders
on Mar 3, 2020 at 3:50:26 am

It seems I can't get it to work. I'm creating a simple gui button and a textfield, so when you enter a number, let's say 3, when you click the button it adds 3 sliders to the selected layer(s), but I don't know how to connect the textfield value to the amount of copies.
any quick workaround?

Return to posts index

Scott McGee
Re: extendscript: onClick add n sliders
on Mar 3, 2020 at 1:36:08 pm

Hopefully this helps.

I've added a safety net so that if you don't add a number it won't crash. It will just alert that a number hasn't been added.

Essentially what it is doing it. The layer or layers you've selected, it then runs a separate loop and adds based on the value of your text box.

var win = new Window('palette', "ADD SLIDERS", undefined);
var numOne = win.add("edittext",undefined,"ENTER NUMBER HERE");
var btn = win.add("button",undefined,"ADD SLIDERS");

btn.onClick = function(){

var curItem = app.project.activeItem;
var selectedLayers = curItem.selectedLayers;

for (var j = 0; j < selectedLayers.length; j++) {
var myLayer = selectedLayers[j];

alert("Enter a number")
var num = parseInt(numOne.text);
for(var i = 0; i < num; i++) {
myLayer.Effects.addProperty("Slider Control")("Slider");

Return to posts index

Peter Zeet
Re: extendscript: onClick add n sliders
on Mar 3, 2020 at 4:47:11 pm

wow, thanks! works like a charm!

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 All Rights Reserved