Skip to main content
Participant
May 17, 2018
Answered

Random number counter- up only

  • May 17, 2018
  • 2 replies
  • 4127 views

Thank in advance-

Despite my best efforts in trying multiple expressions, I can NOT get a sequence of numbers (from 47-426) to randomly count up over a 12 minute timeline.

I can get it to either count up by 1- 2,3,4,5 etc.

or I can get it to count all numbers randomly up and down.

I just need it to start at 47 and count randomly up to 426...

I know I am probably missing just one piece.

Any help?

Thanks

    This topic has been closed for replies.
    Correct answer Rick Gerard

    Add an Effects>Expression Controls>Slider Control to the text layer then add this expresion:

    v = Math.floor(effect("Slider Control")("Slider"));

    r = random(1, 9);

    n = Math.floor(v + r);

    if (v <= 43 || v >= 426) v

    else n

    Animate the slider between 43 and 426. Unless you take a lot of time you'll end up with random increasing whole numbers. There may be the occasional glitch but numbers will be changing on every frame so it will be hard to tell if the counter goes backward for one frame.

    If I thought about this a little more I could probably refine this idea so that the numbers would only increase by adding a time element to the mix.

    2 replies

    Participant
    October 12, 2023

    This works for me:

    f = 0.4;

    a = 0.6;

    seedRandom(f,true);

    z = random(f,a);

    posterizeTime(z);

     

    num=effect("Slider Control")("Slider");

    Math.round(num);

    Rick GerardCommunity ExpertCorrect answer
    Community Expert
    May 17, 2018

    Add an Effects>Expression Controls>Slider Control to the text layer then add this expresion:

    v = Math.floor(effect("Slider Control")("Slider"));

    r = random(1, 9);

    n = Math.floor(v + r);

    if (v <= 43 || v >= 426) v

    else n

    Animate the slider between 43 and 426. Unless you take a lot of time you'll end up with random increasing whole numbers. There may be the occasional glitch but numbers will be changing on every frame so it will be hard to tell if the counter goes backward for one frame.

    If I thought about this a little more I could probably refine this idea so that the numbers would only increase by adding a time element to the mix.

    Participant
    May 17, 2018

    That certainly helps- how can I slow down the changing numbers? every frame is too fast.

    I'm new to expressions - I can figure out little parts at a time but cant seem to wrap it all together, yet

    Thank you!

    Community Expert
    May 17, 2018
    1. Pre-compose your text layer
    2. Open the Composition Settings and adjust the frame rate to the number of times per second you want the counter to change
    3. Open the Advanced tab of the comp and select Preserve Frame Rate with Nested
    4. Return to the main comp

    If you want the count to increase 4 times per second then set the frame rate to 4, if you want 10 changes per second set the frame rate to 10.