Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Sebastian Moreno on June 2, 2016 at 8:39 pm

    Hi all
    I am new scripting in After effects. The problem is that I have a GUI with a button that creates a shape and a second button should change the opacity of this shape. But when I click the second button nothing happens. I tried several things and hierarchies but the sintax to recall the shape layer isnt working somehow.

    Any Ideas???

    var groupTwo = myWin.add(“group”, undefined, “GroupTwo”);
    groupTwo.alignment =[“fill”,”fill”];
    groupTwo.orientation = “row”;
    var p2 = groupTwo.add (“panel”,undefined, ” Cursor type”);
    p2.alignment = [“fill”,”fill”];
    p2.orientation = “row”;
    p2.alignChildren = [“”,”fill”];

    var btn4 = p2.add(“iconbutton”, undefined, “image.png”,”IconButton”);
    var btn5 = p2.add(“iconbutton”, undefined, “image2.png”,”IconButton”);

    btn4.onClick = function(){

    var testComp = app.project.items.addComp(‘testComp’,200,200,1,20,25);
    var shapeLayer = testComp.layers.addShape();
    shapeLayer.property(“Contents”).addProperty(“ADBE Vector Group”);
    shapeLayer.property(“Contents”).addProperty(“ADBE Vector Shape – Ellipse”);
    shapeLayer.property(“Contents”).addProperty(“ADBE Vector Graphic – Fill”);

    }

    btn5.onClick = function(){

    //———->> HERE NOTHING IS HAPPENING <<------------------- var opaCity = shapeLayer.property("Transform").property("Opacity").setValue(10); }

    Sebastian Moreno replied 9 years, 11 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    June 2, 2016 at 11:18 pm

    My guess is that it’s because you declare you shapeLayer variable inside the btn4 function so it’s not available outside that function. I guess you could declare it outside both functions:

    var shapeLayer = null;

    inside the btn4 function:

    shapeLayer = testComp.layers.addShape();

    inside the btn5 function:

    if (shapeLayer != null){
    etc.

    Dan

  • Sebastian Moreno

    June 3, 2016 at 8:58 am

    Thank you Dan, Indeed was the declaring, I am rewriting all to declare and use a respective function inside the button actions!!!
    Great .
    Thanks again

  • Sebastian Moreno

    June 6, 2016 at 12:02 pm

    Simple but weird. I can’t get to use addKey where the Current time indicator stands. I just want to add a key frame to the shape layer:

    opaCity = shapeLayer.property(“Transform”).property(“Opacity”).setValue(0);

    btn6.onClick = function(){

    shapeLayer.property(“Transform”).property(“Opacity”).addKey(KeyframeTime);

    }

    ////I tried this and other couple of things for this” KeyframeTime”:

    KeyframeTime = app.project.items.testComp.layers.shapeLayer.keyTime(1). — and isnt working

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