Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions extendscript: onClick add n sliders

  • extendscript: onClick add n sliders

    Posted by Peter Zeet on March 3, 2020 at 3:50 am

    hi!
    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?
    thanks!

    Peter Zeet replied 6 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Scott Mcgee

    March 3, 2020 at 1:36 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];

    if(isNaN(numOne.text)){
    alert(“Enter a number”)
    }else{
    var num = parseInt(numOne.text);
    for(var i = 0; i < num; i++) {
    myLayer.Effects.addProperty(“Slider Control”)(“Slider”);
    }
    }
    }
    }

    win.show();

  • Peter Zeet

    March 3, 2020 at 4:47 pm

    wow, thanks! works like a charm!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy