Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Error fallback method(s)

  • Error fallback method(s)

    Posted by Jurgen Koch on September 23, 2020 at 2:00 pm

    My default template uses a ‘master color comp’ with a series of colors,  (ColorControl_01, ColorControl_02, etc) 

    Normally a project will start with a series of brand colors, and as it develops, the colors will shift slightly by way of the brand guidelines being updated by the client/agency. 

    I’ve been using a system that pulls the desired colors from the color comp with the expression:

    var colorNum = thisLayer.name.split(" ")[0];
    comp("_colorMaster").layer("ColorMaster").effect("ColorControl_"+colorNum)("Color");

    So the layer name determines the color of the fill, IF the first two characters of the layer name are numbers, followed by a space. What I would like to do is create a fallback so that if the layer name does NOT start with two numbers, it will disable the expression, (or render with #00FF33 ??)

    It seems to be an if/than situation, but evaluating the characters seems to be where I am getting stuck. 

    Thanks in advance

    Jurgen Koch replied 5 years, 11 months ago 1 Member · 1 Reply
  • 1 Reply
  • Jurgen Koch

    September 23, 2020 at 3:53 pm

    solution from Rob Barrett:

    var colorNum = thisLayer.name.split(" ")[0];
    if (!isNaN(colorNum)) {
    comp("_colorMaster").layer("ColorMaster").effect("ColorControl_"+colorNum)("Color");
    } else {
    [0,255,0,255]
    };

    if the layer name starts with 01, 02, 03, 04, etc it will reference the color in the color master, otherwise, it gives is pure green

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