Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Scripting Loops

  • Scripting Loops

    Posted by Spooky on September 27, 2005 at 8:40 pm

    OK,

    I’m an Expressions idiot. I do fine in Actionscript but haven’t done enough in AE to get my head working right. I am working on a piece where I have some small objects that need to pulse/glow. I’m not sure how I am going to finally go about doing it but I’ll probably want a cycling script to run the animation. So for an example, let’s say I do it by cycling the Blur amount between 1 to 5 and to 1 again every second. How would I do that?

    And as I understand it (correct me if I’m wrong), there are no global variables in AE, so if I have five objects doing this I have to create a script for each one, or is there a way to put the script on one layer and have it control the other layeers so that they are all pulsing at slightly offset times?

    All you AE script geniuses need to write some more tutorials – there aren’t enough out there.

    Thanks!

    Spooky replied 20 years, 7 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    September 27, 2005 at 9:27 pm

    Well, you could probably set up an expression for a slider that other layers could use to control their cycling, but I think it would be easier to apply an expression like this to the blur of each layer:

    seedRandom(index,true)
    phase = random(Math.PI*2);
    freq = 1.0;
    2*Math.sin(time*freq*Math.PI*2 + phase) + 3

    Especially if you can just duplicate the first layer to get the effect you want (each copy will pulse at a different time).

    Dan

  • Spooky

    September 27, 2005 at 9:50 pm

    Thanks Dan,

    quick question. on the call to the seedRandom what exactly are index and true flagging? Not having AE in front of me, can I change the 2 and 3 in 2*Math.sin(time*freq*Math.PI*2 + phase) + 3 to variables?

    For example:
    in = 2;
    out = in + 1;
    in*Math.sin(time*freq*Math.PI*2 + phase) + out

    Just trying to figure out what’s going on here. And do you not need a semicolon after each expression?

  • Dan Ebberts

    September 27, 2005 at 9:57 pm

    >on the call to the seedRandom what exactly are index and true flagging?

    “index” is the actual seed, “true” says to make it timeless (i.e. random values will persist from frame to frame)

    >can I change the 2 and 3 in 2*Math.sin(time*freq*Math.PI*2 + phase) + 3 to variables?

    Sure.

    >And do you not need a semicolon after each expression?

    It’s optional on the last line. It’s really optional on most lines – it’s just safer (and good practice) to put it in.

    Dan

  • Spooky

    September 27, 2005 at 10:54 pm

    Thanks!

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