Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Easy Expressions Question (I think)

  • Easy Expressions Question (I think)

    Posted by Ken on March 23, 2006 at 6:52 pm

    Really new to expressions and I’m using an expression to generate random numbers in a text element. Works great, but is there a way to get whole numbers only instead of numbers with a ton of decimal places?

    posterizeTime(10);
    random(10,90)

    *This one is just a bonus question, but can I have it generate random numbers for 1 second and then land on a specified number for X seconds and then go back to random, repeat, etc….???

    Thanks in advance!
    Ken

    Ken replied 20 years, 1 month ago 2 Members · 5 Replies
  • 5 Replies
  • Mylenium

    March 23, 2006 at 7:13 pm

    Create a checkbox expression control and name it “use random” or something like that, then animate it on and off. Use below code:


    posterizeTime(10);

    randomizer=effect(“use random”)(“Checkbox”);

    if (randomizer == 1)
    {Math.round(random(10,90))}
    else {5}

    If you need to change the value for the fixed number over time, use a slider to feed your expression with it.

    Mylenium

    [Pour Myl

  • Ken

    March 23, 2006 at 7:22 pm

    You Rock! I’ll give it a whirl. If it doesn’t work, I’m sure it will be something I did wrong.

  • Ken

    March 23, 2006 at 7:52 pm

    OK…didn’t work for me and I looked at over and over. I did what you said and added an expression to the “Source Text” via pickwhip linking it to the checkbox effect. When I connect the two, the text in my comp changes to a “1” and does nothing. When I add the “Math.round(random(10,90))” code to the “Source Text” it works great.

    This will work for the time being, but the code you sent looks like it would solve my starting and stopping problem.

    Am I doing something wrong?

  • Mylenium

    March 23, 2006 at 8:00 pm

    I’m not really sure if I understand you correctly. All that would be required is to copy and paste the expression to the source text and add the checkbox somewhere. Your description sounds like it is using the checkbox states (on/ off equate to 1/0) for the text while it should only act as the condition that triggers the random function.

    Mylenium

    [Pour Myl

  • Ken

    March 23, 2006 at 8:35 pm

    Didn’t I say if it doesn’t work it is my fault?

    WORKS BEAUTIFULLY!

    For some reason I thought I had to link it to the checkbox effect.

    Thanks again,
    Ken

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