FORUMS: list search recent posts

How to get a Blinking Effect using expressions?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
James Ceguerra
How to get a Blinking Effect using expressions?
on Jan 2, 2011 at 5:15:45 pm

Hello everyone, Random person here.
Question:
I have a image of a light, sorta like a LED. I want it to blink to a song's BPM, my plan to do this was to use audacity to generate the bpm, figure out the time between each beat and set opacity keyframes and then make it loop.
I managed to get all that done except for the loop part...
i tried searching online for 'blinking in after effects' and i found some stuff that i couldn't understand except something about expressions?
I managed to find one expression however I have no idea how to determine the timer for it...
the expression is
blinkSpeed = 1;
lowOpacity = 10.0;
highOpacity = 90.0;
opNormal = (Math.cos(blinkSpeed*time*Math.PI*2)+1)/2;
linear(opNormal,0,1,lowOpacity,highOpacity);
and found it here
http://video.ucf.edu/knowledge/reference/pdf/adobe/aft6blink.pdf
Can I get some help please?


Return to posts index


Dan Ebberts
Re: How to get a Blinking Effect using expressions?
on Jan 2, 2011 at 6:14:16 pm

I think you'd just need to change the first line to convert your bpm value to frequency, like this:

blinkSpeed = your_bpm_value/60;


Dan



Return to posts index

James Ceguerra
Re: How to get a Blinking Effect using expressions?
on Jan 5, 2011 at 6:32:12 pm

Thanks for the help :)


Return to posts index


jack cloud
Re: How to get a Blinking Effect using expressions?
on Aug 14, 2011 at 10:58:33 pm

Need a blink expression that can control a layers opacity from a nested comp.

Is there a way that a short nested "BLINK" comp can have an expression on it so that wherever it appears in the timeline ANOTHER LAYER'S Opacity is changed from 100% to 0% and the start of the nested comp and then back to 100% at the end of the nested comps duration within the main comp? In effect, I can then drop copies of the 6 frame "Blink" nested comp anywhere along the time line and it will drive an "eyelash" layer's opacity?

cheers


Return to posts index

Dan Ebberts
Re: How to get a Blinking Effect using expressions?
on Aug 15, 2011 at 12:19:52 am

Assuming your BLINK subcomp is a layer in the comp with the eyelash layer, you would apply something like this to the eyelash layer's opacity:

blink = thisComp.layer("BLINK");
time < blink.inPoint || time > blink.outPoint ? 100 : 0


Dan



Return to posts index

jack cloud
Re: How to get a Blinking Effect using expressions?
on Aug 15, 2011 at 4:09:23 pm

Hi Dan,
thanks so much for that. I applied the expression and it returned this error.
Expression was applied to "eyelash" layer's Opacity:

blink = thisComp.layer("blink 2").transform.opacity;
time < blink.inPoint || time > blink.outPoint ? 100 : 0

and returned error was:
Warning: Class 'Property' has no property or method named 'inPoint'.
Expression disabled
Error occurred in line 2.

Now I applied another expression like this;

op = thisComp.layer("blink").transform.opacity;

100 - op

AND it worked as long as I keyed the 'Blink' layer's Opacity

I'd like to try and get yours to work because it seems that expression functions from the subcomp's mere appearance in the timeline regardless of any keyframes AND I'll have many occurrences of the "Blink" layer duplicated anytime I want the character to blink.

Thanks again for your help. You're a genius Dan
best,
Jack

blink = thisComp.layer("blink 2").transform.opacity;
time &lt; blink.inPoint || time > blink.outPoint ? 100 : 0

OR

op = thisComp.layer("blink").transform.opacity;

100 - op


cheers


Return to posts index


jack cloud
Re: How to get a Blinking Effect using expressions?
on Aug 15, 2011 at 4:23:52 pm

I also noted that if I use the:

op = thisComp.layer("blink").transform.opacity;

100 - op

expression the eyelash layer will ONLY look at the 1st layer in heirarchy to do the opacity change. All other instances of "Blink" subComp have no effect. Oh boy.

cheers


Return to posts index

Dan Ebberts
Re: How to get a Blinking Effect using expressions?
on Aug 15, 2011 at 4:25:08 pm

Hmmm... The expression I posted was for the eyelash layer's opacity, not the blink layer. I apologize if you already know this, but an expression can only affect the property it's applied to. So you can't have an expression in one layer affect opacity in another layer. The expression I posted should (although I didn't test it) make the eyelash layer invisible between the in and out points of the blink layer.

Dan



Return to posts index

jack cloud
Re: How to get a Blinking Effect using expressions?
on Aug 15, 2011 at 4:36:57 pm

Hi Dan,
my bad. I applied the expression to the correct "eyelash" layer Opacity BUT pickwhipped it to the "Blink" layer Opacity rather than the layer itself. All good now!

However
Any thoughts on how to do this with 10 or 20 instances of the "blink" layer in the timeline?

Thanks again sir Dan

cheers


Return to posts index


Dan Ebberts
Re: How to get a Blinking Effect using expressions?
on Aug 15, 2011 at 4:55:30 pm

If the layers are contiguous, you could use relative indexing from the first (topmost) instance, like this to get at the 5th instance, for example:

thisComp.layer(thisComp.layer("Blink"),4).inPoint

Dan



Return to posts index

jack cloud
Re: How to get a Blinking Effect using expressions?
on Aug 15, 2011 at 5:33:34 pm

Ah huh, does this look right to you?
Im only getting it to read the last instance now. I thought it'd be simple sorry to bug you with it, but of course this animation is sitting here waiting on me in the studio.

cheers


Return to posts index

jack cloud
Re: How to get a Blinking Effect using expressions?
on Aug 15, 2011 at 6:08:55 pm

Oops here's the link:

http://gallery.me.com/jackcloud#100155/blink_timeline

thisComp.layer(thisComp.layer("Blink"),4).inPoint
time < blink.inPoint || time > blink.outPoint ? 100 : 0

I got an error at the end on line one. Didn't like the .inPoint after the ,4)
Without the .inPoint it works but only on 1 instance.

Still trying though

cheers


Return to posts index


Dan Ebberts
Re: How to get a Blinking Effect using expressions?
on Aug 15, 2011 at 7:14:54 pm

This should target the 3rd instance:

myInstance = 3;
blink = thisComp.layer(thisComp.layer("Blink"),myInstance-1);
time < blink.inPoint || time > blink.outPoint ? 100 : 0


Dan



Return to posts index

jack cloud
Re: How to get a Blinking Effect using expressions?
on Aug 15, 2011 at 7:27:02 pm

Hi Dan, thanks so much for your timely replies. This is useful knowledge as well.
I may have been unclear though. I would like the eyelash to respond to ALL instances of the Blink
and so far I've only been able to get it to one instance (occurrence). I did notice that I can change the number and it would see the Blink above or below BUT reference ALL has not been successful yet.

I could use index I suppose but then it would reference the other layers that are NOT Blink as well eh?

cheers


Return to posts index

Dan Ebberts
Re: How to get a Blinking Effect using expressions?
on Aug 15, 2011 at 7:38:13 pm

Try this:


numInstances = 5;
idx = thisComp.layer("Blink").index;
gotBlink = false;
for (i = 0; i < numInstances; i++){
L = thisComp.layer(idx+i);
if (time >= L.inPoint && time < L.outPoint) gotBlink = true;
}
gotBlink ? 0 : 100



Dan



Return to posts index


jack cloud
Re: How to get a Blinking Effect using expressions?
on Aug 15, 2011 at 7:53:40 pm

THAT DID IT!!! Your a rockstar in my book Dan!
I only wish I understood more clearly this code you've written
I get the 1st 3 variables
but can I learn about the for statement on motionscripts
Also the i statement. I don't see a variable defining it?
Whatever you did works and works well. All I have to do is change the expression if I add more instances.
I could probably connect that to a slider and just count out the number of instances, then I can leave the expression alone.
YOU ROCK did I already say that?!

This code is quite useful for grabbing a specific number of layers in a comp and doing something with them.



numInstances = 5;
idx = thisComp.layer("Blink").index;
gotBlink = false;
for (i = 0; i < numInstances; i++){
L = thisComp.layer(idx+i);
if (time >= L.inPoint && time < L.outPoint) gotBlink = true;
}
gotBlink ? 0 : 100

cheers


Return to posts index

Dan Ebberts
Re: How to get a Blinking Effect using expressions?
on Aug 15, 2011 at 8:12:46 pm

The for statement is basic core JavaScript. The i variable is defined in the for statement. In fact in a script I would write it more formally, like this:


for (var i = 0; i < numInstances; i++){


This version should automatically count the instances for you:


blinkName = "Blink";
idx = thisComp.layer(blinkName).index;
gotBlink = false;
while (idx <= thisComp.numLayers){
L = thisComp.layer(idx);
if (L.name != blinkName) break;
if (time >= L.inPoint && time < L.outPoint){
gotBlink = true;
break;
}
idx++;
}
gotBlink ? 0 : 100


Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]