Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Script works fine as solo composition, but syntax error when imported to project

  • Script works fine as solo composition, but syntax error when imported to project

    Posted by Lee Pines on October 15, 2020 at 3:32 pm

    I have this script that I’m using to control the color of multiple shapes in one composition. It’s connected to a slider, so I can use the slider to change a set of predetermined colors of all shapes that should be that color.

    So, for example, I have a bunch of text on a colored background and I want to use the slider to change the color of all the background shapes.

    This is my expression for the slider:

    slider = Math.round(thisComp.layer(“Color”).effect(“Slider Control”)(“Slider”));

    which is followed by this for each color:

    colorValue1 = thisComp.layer(“Color”).effect(“Color Control”)(“Color”);

    if(slider==1){colorValue1};

    It works beautifully in a solo composition, BUT when I import this composition into another, I get the following error on the first line:

    Error: Undefined value used in expression (could be an out of range array subscript?)

    Does anyone know why this error happens?

    Thanks!

    Lee Pines replied 5 years, 7 months ago 2 Members · 7 Replies
  • 7 Replies
  • Brendon Murphy

    October 15, 2020 at 4:47 pm

    Is there more than one layer with the name “Color” in your new comp?

  • Lee Pines

    October 15, 2020 at 4:50 pm

    No, I keep it in the composition and drop the composition into a new comp. It’s weird, there’s nothing else in the whole project with the same name

  • Brendon Murphy

    October 15, 2020 at 5:23 pm

    Oh – I wonder if “thisComp” starts referencing the parent comp. Try calling the comp more specifically, by name.

  • Lee Pines

    October 15, 2020 at 5:24 pm

    Thanks! How would I do that?

  • Brendon Murphy

    October 15, 2020 at 7:29 pm

    I honestly can’t duplicate your problem. You are using this setup in say, “Comp 1”. When you place the entire Comp 1 into Comp 2, the expression in Comp 1 breaks? Is it just when you are in Comp 2?

    You can try using: comp(“your comp name here”)

    instead of thisComp.

  • Lee Pines

    October 16, 2020 at 8:57 am

    Thanks for the help. I tried the comp name script you suggested, but the same error comes up. What happens is: if I open the project alone, the script works. But, if I import the project into another project, the script breaks

  • Lee Pines

    October 16, 2020 at 9:04 am

    I may have figured something out. The script works fine with one color, but when I add another line, that’s when it breaks. Here’s the whole script. Maybe you can find out where I went wrong?

    slider = Math.round(thisComp.layer(“Color”).effect(“Slider Control”)(“Slider”));

    colorValue1 = thisComp.layer(“Color”).effect(“Color Control”)(“Color”);
    colorValue2 = thisComp.layer(“Color”).effect(“Color Control 2”)(“Color”);
    colorValue3 = thisComp.layer(“Color”).effect(“Color Control 3”)(“Color”);
    colorValue4 = thisComp.layer(“Color”).effect(“Color Control 4”)(“Color”);
    colorValue5 = thisComp.layer(“Color”).effect(“Color Control 5”)(“Color”);
    colorValue6 = thisComp.layer(“Color”).effect(“Color Control 6”)(“Color”);
    colorValue7 = thisComp.layer(“Color”).effect(“Color Control 7”)(“Color”);
    colorValue8 = thisComp.layer(“Color”).effect(“Color Control 8”)(“Color”);
    colorValue9 = thisComp.layer(“Color”).effect(“Color Control 9”)(“Color”);
    colorValue10 = thisComp.layer(“Color”).effect(“Color Control 10”)(“Color”);
    colorValue11 = thisComp.layer(“Color”).effect(“Color Control 11”)(“Color”);
    colorValue12 = thisComp.layer(“Color”).effect(“Color Control 12”)(“Color”);
    colorValue13 = thisComp.layer(“Color”).effect(“Color Control 13”)(“Color”);

    if(slider==1){colorValue1};
    if(slider==2){colorValue2};
    if(slider==3){colorValue3};
    if(slider==4){colorValue4};
    if(slider==5){colorValue5};
    if(slider==6){colorValue6};
    if(slider==7){colorValue7};
    if(slider==8){colorValue8};
    if(slider==9){colorValue9};
    if(slider==10){colorValue10};
    if(slider==11){colorValue11};
    if(slider==12){colorValue12};
    if(slider==13){colorValue13};

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