Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions random expression executed once

  • random expression executed once

    Posted by Peter Hriso on November 5, 2009 at 4:06 am

    I have the following expression on a text source:

    var myArray = [“beans”,”rice”,”tacos”,”bbq”];
    var i = Math.floor(random(myArray.length));
    myArray[i]

    I need a expression to execute one time and not every frame when the playhead plays through the comp. How can I run an expression to execute only at the beginning of a timeline and not on every frame? I don’t see any triggers/events for detecting the first run of the timeline, for example an onEnterFrame handler function that actionscript utilizes.

    thnx in advance

    var myArray = ["beans","rice","tacos","bbq"];
    var i = Math.floor(random(myArray.length));
    myArray[i]

    Peter Hriso replied 16 years, 6 months ago 3 Members · 4 Replies
  • 4 Replies
  • Xinlai Ni

    November 5, 2009 at 5:15 am

    Maybe I missed your point, but why do you want a random function to choose one out of four choices and keep it forever? Why not just pick one manually and assign it and not change it throughout the time?

    Xinlai Ni
    Software Engineer, Google Inc.

  • Peter Hriso

    November 5, 2009 at 1:59 pm

    I have a comp generating particles. I am attempting to customize the look of the particles with animated text. I have attached a second comp to each individual particle to design the animated look and feel. I am using the second comp to design the animated words but I need it to be an array of different words.

  • Dan Ebberts

    November 5, 2009 at 2:47 pm

    seedRandom() is what you’re looking for. Like this:

    var myArray = [“beans”,”rice”,”tacos”,”bbq”];
    seedRandom(index,true);
    var i = Math.floor(random(myArray.length));
    myArray[i]

    Dan

  • Peter Hriso

    November 5, 2009 at 2:51 pm

    Thanks for the help.

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