Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions What’s wrong with this non random color array picking expression?

  • What’s wrong with this non random color array picking expression?

    Posted by Maximilian Yuen on July 10, 2018 at 4:37 am

    I am getting syntax error and I am pretty sure it’s either the double bracket or the slider value didn’t get translated when putting into options?

    Thanks.

    R1=thisComp.layer("color").effect("R1")("Slider");
    G1=thisComp.layer("color").effect("G1")("Slider");
    B1=thisComp.layer("color").effect("B1")("Slider");
    options = [[R1],[G1],[B1], 255], [0, 255, 0, 255], [0, 0, 255, 255]];
    seedRandom(index, true);
    r = Math.floor(random(3));
    options[r]/255;

    Kalleheikki Kannisto replied 7 years, 9 months ago 2 Members · 3 Replies
  • 3 Replies
  • Kalleheikki Kannisto

    July 10, 2018 at 7:14 am

    No need to put the individual slider values in brackets (Plus you were missing one opening bracket for the first set of colors).

    Kalleheikki Kannisto
    Senior Graphic Designer

  • Maximilian Yuen

    July 10, 2018 at 7:18 am

    you mean like this? that’s the first I try but it don’t work either 🙁


    R1=thisComp.layer("color").effect("R1")("Slider");
    G1=thisComp.layer("color").effect("G1")("Slider");
    B1=thisComp.layer("color").effect("B1")("Slider");
    options = [[R1,G1,B1, 255], [0, 255, 0, 255], [0, 0, 255, 255]];
    seedRandom(index, true);
    r = Math.floor(random(3));
    options[r]/255;

  • Kalleheikki Kannisto

    July 10, 2018 at 5:58 pm

    Yes, it works just fine like that. Perhaps it just does something different from what you expect? It picks one of those three color values at random. It just does that once per layer, so if you duplicate the layer a number of times, the property will result in different colors wjhere this expression is used.

    Kalleheikki Kannisto
    Senior Graphic Designer

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