Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Script to change colors of all masks on a layer

  • Script to change colors of all masks on a layer

    Posted by Corey Drake on September 26, 2011 at 10:35 pm

    I’m wondering how to return an array for all the masks on a layer. I’ve put some of the code into the expression box below for what I’m trying to do. Basically I want to press this button to turn all the masks red on a particular layer. Masks is returning ‘undefined’. I think it may not be returning an array? If so, what does that command return?

    function OnRedClick() {
    var activeItem = app.project.activeItem;
    var layers = activeItem.selectedLayers;
    for (var i = 0; i <layers.length; i++) {
    var currLayer = layers[i];
    //This is where I think my problem is:
    var masks = currLayer.Masks;
    for (var j = 0;j &lt; masks.length; j++) {
    var currMask = masks[j];
    currMask.color = [1,0,0];
    }
    }
    }

    Corey Drake replied 14 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 26, 2011 at 11:40 pm

    Something like this, I think:


    for (var j = 1; j <= currLayer.property("Masks").numProperties; j++)
    currLayer.property("Masks").property(j).color = [1,0,0];

    Dan

  • Corey Drake

    September 27, 2011 at 12:48 am

    Great thanks.

    A quick tip for anyone who might be looking at this post in the future: My changes didn’t work at first because I didn’t realize Dan had changed the initial value of j to 1 instead of 0. Properties start at 1 I now realize.

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