Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Extendscript How Tos

  • Extendscript How Tos

    Posted by Billy Sides on May 1, 2014 at 9:52 pm

    For my first how to:

    I’m creating a text layer, then I want to rename that layer…but I can’t for the life of me figure out what the correct code should be.

    Here’s what I have:

    app.project.activeItem.layers.addText("dog");
    app.project.activeItem.layer(1).text.name("cat");

    The reason I want to rename it is because I want to search based off of the layer name, not the source name…or maybe you can do it in one line???

    Thanks for your help.

    -bsides

    Billy Sides replied 12 years ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    May 1, 2014 at 11:03 pm

    Just change your second line to this:

    app.project.activeItem.layer(1).name = “cat”;

    Even better would be to put the new layer object in a variable:

    var myTextLayer = app.project.activeItem.layers.addText(“dog”);
    myTextLayer.name = “cat”;

    Dan

  • Billy Sides

    May 2, 2014 at 5:51 am

    Thanks Dan!

    Ok here’s my next issue:

    I want to increment a variable each time a button is clicked and set its value to 0. My brain says this will work…but nope.


    function onButtonClick()
    {
    i++;
    var newVariable[i] = 0;
    }

    I’ve tried several variants of this with no luck.
    Any help is appreciated.

    Thanks!

    -bsides

  • Dan Ebberts

    May 2, 2014 at 6:05 am

    I’m not sure exactly what you’re trying to do, but variable i would have to be defined outside the scope of the function (i.e. as a global variable) for the value to persist from one click to the next.

    Dan

  • Billy Sides

    May 2, 2014 at 8:13 am

    Yup it is, this is just the function called when I click a button.

    Basically what I’m trying to accomplish is setting the text layers base value as 0, but each time it has to have a unique variable so I can change it later. Or I can just call to get the texts value, but from what I’ve read it doesn’t just return the string. Thought maybe there was an easier way.

    -bsides

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