Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions One expression 2 sliders

  • One expression 2 sliders

    Posted by Vincenzo Marchese Ragona on June 1, 2021 at 2:12 pm

    Hi!

    I’m currently working on an animation where i have to play with a text leading and size.

    I’ver set the expressions


    newStyle = style.setFontSize(effect(“Size”)(“Slider”));

    newStyle = style.setLeading(effect(“Leading”)(“Slider”));

    But when I connect them to the slider only one of the two works. Almost like it goes in conflict. Is there maybe a way to calculate and retain the leading/size ratio and attaching it to one slider only so it feels consistent all the way?

    Here’s attached an image for reference https://imgur.com/a/aWAPYPm

    Thanks!!

    Vincenzo Marchese Ragona replied 4 years, 9 months ago 3 Members · 9 Replies
  • 9 Replies
  • Filip Vandueren

    June 1, 2021 at 3:19 pm

    Combine both values into the same style by chaining the methods:

    newStyle = style.setFontSize(effect(“Size”)(“Slider”)).setLeading(effect(“Leading”)(“Slider”));
  • Vincenzo Marchese Ragona

    June 1, 2021 at 3:43 pm

    Hey thanks for your answer, I’m presenting me this error now.

  • Filip Vandueren

    June 1, 2021 at 3:46 pm

    The website converted straight “quotes” to curly “quotes”.

    JavaScript needs straight single or double quotes.

  • Vincenzo Marchese Ragona

    June 1, 2021 at 3:54 pm

    that worked! Thank you so much!

  • Wyatt Kedinger

    June 1, 2021 at 7:11 pm

    You could also try this, which I did for a specific branded treatment that needed to retain the same font size to leading ratio at scale. This allows you to scale up the font size with the slider and the leading will follow.

    You’ll need to do the math to come up with the ratio of size to leading and replace the ‘x’ with your number. Then, create a slider and then put your slider name in place of “Font Size”.

    Wyatt

    
    

    // Font size multiplied by x (x = the ratio of font size to leading)

    style.setFontSize(effect("Font Size")("Slider")).setAutoLeading(false).setLeading(effect("Font Size")("Slider")*x).setFont("Axiforma-Black");

  • Vincenzo Marchese Ragona

    June 2, 2021 at 8:29 am

    Sounds awesome Wyatt! Will try now! Thank you!

  • Vincenzo Marchese Ragona

    July 22, 2021 at 9:24 am

    Hey, is me again! I’m now trying to have the text changing based on this expression

    style.setFontSize(effect("Font Size")("Slider")).setAutoLeading(false).setLeading(effect("Font Size")("Slider")*0.80);
    effect("Slider Control")("Slider").value.toFixed()+'K';

    But unfortunately doesn’t seem to be working when together. Is there something wrong with the format?

  • Filip Vandueren

    July 22, 2021 at 10:59 am

    I think you want to use the last line as the text ? -> add the setText() method to the style.

    style
    .setFontSize(effect("Font Size")("Slider").value)
    .setAutoLeading(false)
    .setLeading(effect("Font Size")("Slider").value*0.80)
    .setText(effect("Slider Control")("Slider").value.toFixed()+'K');


  • Vincenzo Marchese Ragona

    July 22, 2021 at 11:09 am

    amazing! This works! Thanks!
    The only problem I’m facing is that the size slider goes only up to a certain number (1296?) which might be a limitation of the font actually. Is there any way to bypass that? maybe multiplying the expression by 2?

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