4 Replies Latest reply on Jan 21, 2009 5:20 AM by Andy Bay

# Trying to build a simple expression

Hi!

Here's what I'm trying to do:

On layer 1 I have wiggle flashing the opacity of that layer.

On layer two I have a slider linked to the frequency of the expression in layer 1.

On the slider value property I have again wiggle so that the slider gets random values also.

Now I would like the slider value to remain 0 most of the time. I would like it to be other than 0 only if gets a bigger value than 1. In other words if the wiggle expression gives the slider a value like 0.8 then I would like it to be 0. Only if wiggle gives the slider a value that is bigger than 1, would I like the slider to keep that actual value.

What am I actually looking for? I'm trying to have a light sign strobe in a fast (random) frequency at a random interval. There might be a smarter way to do it, and if so, then please let me know. Even if there is a smarter way, I would be curious on how to accomplish this with an if/else expression. Here's what I tried (I'm a total newbie on expressions)

wiggle (0.02, 2);
if (value < 1) {

0

}else{ value ; }

I know I know, it's terrible. First of all I don't know if I can even use wiggle in the beginning of an expression like that. Secondly I have no idea on what to call the slider value in this expression (I mean on the second line, where I'm trying to tell AE that if the slider is less than 1 then make it 0). And on the last line I'm trying to tell it to use the value that the wiggle feeds it (if it's bigger than 1).

I'm sorry for asking such a question. If anyone can give me advice I will appreciate it greatly!
• ###### 1. Re: Trying to build a simple expression
timer=Math.round(thisLayer.effect("Trigger")("Slider"));
if(timer == 1)
else

Just make sure your first wiggle only generates values between 0 and 1.

Mylenium
• ###### 2. Re: Trying to build a simple expression
Thank you very much for helping!

A lot of new stuff for me in here! If you don't mind, I'll ask you a few questions just in order to understand what the code (that you kindly provided) is doing. If you are busy then I don't expect an answer but if you can spare the time to answer then great!

Here we go :D

1. What is "timer"?
2. What is "trigger"?
3. Why should I use "blink" and not just wiggle?
• ###### 3. Re: Trying to build a simple expression
They are merely variable names to make the code more elegant/ expandable if need be. "timer" simply holds the value of the first slider, "Trigger" is just a reference to this slider, which you should rename this way (as you can with any effect --> hit return, type in a name). "blink" is the variable that holds the final result. Naturally your example is quite simple, but if you had to use the "timer" multiple times, it would save you from having to insert the full reference to the effect every time.

Mylenium
• ###### 4. Re: Trying to build a simple expression
Ok, thank you very much for clearing that out!