Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions error with color epxression

  • error with color epxression

    Posted by Assaf Goldlust on March 3, 2018 at 7:08 pm

    in the book “AE Expressions”
    he gave the following expression

    var red=thisComp.layer("Controls").effect("Red")("Slider");
    var green=thisComp.layer("Controls").effect("Green")("Slider");
    var blue=thisComp.layer("Controls").effect("Blue")("Slider");
    var alpha=1;

    var hsl=
    rgbToHsl=([red,green,blue,alpha])
    hsl[0]+=.5;
    if (hsl[0]>1)hsl[0][H11546]=1;
    var rgb = hslToRgb(hsl);
    rgb

    but keep getting an error that tells me that

    H11546 in class 'global' is missing or dosent exist
    I have compared what i wrote against whats in the book and i dont see why,
    can any of your help me out here?

    Dan Ebberts replied 8 years, 2 months ago 2 Members · 12 Replies
  • 12 Replies
  • Dan Ebberts

    March 3, 2018 at 8:12 pm

    I think it should be like this:

    var red=thisComp.layer(“Controls”).effect(“Red”)(“Slider”);
    var green=thisComp.layer(“Controls”).effect(“Green”)(“Slider”);
    var blue=thisComp.layer(“Controls”).effect(“Blue”)(“Slider”);
    var alpha=1;

    var hsl = rgbToHsl([red,green,blue,alpha]);
    hsl[0]+=.5;
    if (hsl[0]>1)hsl[0] -= 1;
    var rgb = hslToRgb(hsl);
    rgb

    Dan

  • Assaf Goldlust

    March 3, 2018 at 8:19 pm

    wait, so why in the book its looks like this?

  • Dan Ebberts

    March 3, 2018 at 8:27 pm

    It definitely does not look like that in my copy. Maybe you have a newer edition, where it somehow got messed up.

    Dan

  • Assaf Goldlust

    March 4, 2018 at 5:58 am

    Well,this sucks

  • Assaf Goldlust

    March 4, 2018 at 10:40 am

    Any way, i have another queation.
    At some point in the expression he used the code

    hsl[0] + = .5;

    And later he explained:
    “+ = .5” means add .5 to whatever the value already is.

    Im slightly confused,
    What is tge diffrence bewtween the usual
    Value=+.5?

  • Dan Ebberts

    March 4, 2018 at 4:39 pm

    It would be:

    hsl[0] += .5;

    (no space between the + and the = ).

    += is a JavaScript shorthand operator that gives you the same result as:

    hsl[0] = hsl[0] + .5;

    Dan

  • Assaf Goldlust

    March 5, 2018 at 5:46 am

    So if i lets say want to do:
    T=transform.position[0]+5;

    I can instead do?
    transform.position[0]+=5;

  • Dan Ebberts

    March 5, 2018 at 7:54 am

    The first one takes the layer’s x postion, adds 5 to it, and stuffs the result in variable T.

    I don’t think the second one actually does anything (except maybe generate an error). So no, they’re not equivalent.

    Dan

  • Assaf Goldlust

    March 7, 2018 at 4:57 pm

    so whats is this operator function?

    i mean in general not just in the contest of this color expression?

  • Dan Ebberts

    March 7, 2018 at 5:09 pm

    += is one of JavaScript’s assignment operators.

    Where

    x += y

    is the same as

    x = x + y

    Dan

Page 1 of 2

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