Blink 2.0

Published by Harry J. Frank on May 13th, 2007 - in Expressions

A while back, I posted a slightly overly complex method of how to make a layer blink on and off. Just recently, I had an epiphany that I drastically overcomplicated it, as I often do as an animator that moonlights as a programmer. Try applying this newer expression to opacity:


blinkSpeed =10;
n = Math.sin(time*blinkSpeed);
if (n<=0) 0 else 100;

Math.sin(x) will always output a number between 1 and -1. As x increases, Math.sin(x) will output an oscillating series of numbers that go back and forth between 1 and -1, forever and ever. As x increases in speed (ie, how fast the numbers are changing), this series will increase in speed.

In the above expression, you see Math.sin(time*blinkSpeed) being assigned to a variable, n. In the next line, there is a simple if/else saying “If n is less than or equal to 0, pass the value of 0 opacity, otherwise pass the value of 100 to opacity.” As n oscillates back and forth to -1 and +1, the if/else statement is creating a value of either 0 or 100.

This results in a simple blink on and off.

Share

You must be logged in to post a comment.

© © 2011 Toolfarm
CyberChimps WordPress Themes

AE Freemart is Stephen Fry proof thanks to caching by WP Super Cache