Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE AFTER EFFECTS: HomeForumBasicsExpressionsTutorialsPodcastsMotion GraphicsTrainingCinema 4DFAQ

random expression executed once

COW Forums : Adobe After Effects Expressions

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   PRINT   •   NEXT THREAD >>
random expression executed once
by Peter Hriso on Nov 5, 2009 at 4:06:34 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]


Respond to this post   •   Return to posts index

Re: random expression executed once
by Xinlai Ni on Nov 5, 2009 at 5:15: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.


Respond to this post   •   Return to posts index

Re: random expression executed once
by Peter Hriso on Nov 5, 2009 at 1:59:55 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.








Respond to this post   •   Return to posts index


Re: random expression executed once
by Dan Ebberts on Nov 5, 2009 at 2:47:27 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



Respond to this post   •   Return to posts index

Re: random expression executed once
by Peter Hriso on Nov 5, 2009 at 2:51:56 pm


Thanks for the help.

Respond to this post   •   Return to posts index

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   PRINT   •   NEXT THREAD >>


FORUMSTUTORIALSMAGAZINETRAININGVIDEOS - REELSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]