Create a flickering neon light effect.

Moderators: Disciple, zlovatt

Post Reply
Nathan S
Posts: 1
Joined: August 27th, 2004, 7:38 am
Location: Indianapolis, IN

August 27th, 2004, 8:47 am

This expression creates a flickering effect on a layer - similar to a flickering neon light.

It is applied to the OPACITY of the layer. It picks a random number for the opacity value the layer only some of the time, based on whether another random number ("probability") is less than or equal to 1. You can change the likelyhood of a random opacity being selected by changing the value of "probability."

The rest of the time the opacity is set to the value of "opacity_normal" which is set to 100 by default.

This concept be easily adaptable to other times when you only want something to happen some of the time by using the if...else operators. For example - you could apply something similar to the position or rotation of a layer and it would hop around some of the time.

Nathan Shipley
Animator, IMS Productions

Code: Select all

// HIGHER values for probability make a random opacity LESS likely.
// A value of 1 will always create a random opacity, a value of 2 will
// create a random opacity 50% of the time, value of 4 will be 25%, etc.

probability = 6;

// "opacity_normal" is the value set for opacity when the a random
// opacity is NOT chosen.

opacity_normal = 100;

x = random(probability);

if (x <= 1) {
	opacity = random(100);
} else {
opacity = opacity_normal;
}
dsp_418
Posts: 10
Joined: December 5th, 2005, 6:53 am

April 25th, 2007, 7:20 am

Thanks Nathan!
I was looking just for a script like this!
very handy
Post Reply