There is one other type of expression you can create for a particle object (shape node)—a runtime expression. By default, a runtime expression executes each frame during playback. A runtime expression does not execute when you go to the start time (or at the time in which a particle is emitted).
You’ll often create both types of expressions for a particle object—a creation expression that initializes an attribute value in the first frame, and a runtime expression that controls the attribute value in subsequent frames.
BubblesShape.rgbPP = sphrand(1);
The particles flicker in random colors as the animation plays back. The runtime expression controls the RGB PP attribute during playback. Because RGB PP is a per particle attribute, the runtime expression executes for each particle in the object for each frame. For each particle, the expression assigns the RGB PP attribute the output from the execution of the sphrand function with an argument of 1. The sphrand function is one of Maya’s many built-in mathematical functions that are useful in expressions.
The sphrand function with an argument of 1 assigns each particle’s RGB PP color a random vector. The vector represents a random point in a spherical region of radius 1. The left, middle, and right RGB PP color components get a value no less than -1 and no greater than 1. (R, G, and B values less than 0 are treated as 0—a black color).