The Expressions Cheat Sheet

random() gives you a random number between 0 and 1

random() // anywhere between 0 and 1. Updates every frame

Random Rotation

Apply this to a Rotation property:


It might not be very obvious, but if you look closely you can see the image is rotating ever so slightly.
The image gets a new random rotation between 0 to 1 degree, which is very little.

Fortunately for us, we can give random a multiplier!


Now our Rotation property will be randomly set to anywhere between 0 and 360 every frame. Cool, fuzzy but cool.
Let's tone it down a notch:


This is cool, but it almost feels like something is wrong. Oh, I know! Our layer is only leaning to the right. That's because random(10) gives us a number between 0 and 10.
Fortunately for us (we are very lucky today), random is very kind. If we give it two numbers instead of one, it treats them as a range.


That should do the trick. Now the layer should rotate 10 degrees to either direction.

Move in random directions

the Position property usually expects two values in an Array. This should do the trick:

var max = 50;
var randomX = random(-max, max);
var randomY = random(-max, max);
value + [randomX, randomY];

Now we can easily specify what is the maximum amount of randomness we want to add to the original value.
The result is very similar to wiggle(), the difference is that wiggle tends to be smoother and transition between new values slowly and across multiple frames.
Random as mentioned before gives you a completely new value every frame, resulting in a much sharper, more brutal transition.

Random Color (Warning: flashing lights)

A color in expressions is usually represented by an array of normalized values (0 to 1), a value for each color channel (Red, Green, Blue, Alpha).
Although alpha is many times ignored in most color properties, for some reason it might be required.

Either way, to create a new random color every frame we can use the expression below:

[random(), random(), random(), 1];

random() is serving us well here because a value between 0 and 1 is exactly what we need.
Uncheck "Pause" to see the color value changing randomly (warning: flashing lights):