Heres an animation I did yesterday.
Basicly the mel loop checks which objects still have to be transformed/rotated/scaled whatever, and if they are next to ones that are already visible, if they are, they are animated towards the original mesh.
int $x;
//init
if (frame == 1) {
int $z;
for ($z = 159; $z <=338; $z++) {
if ($z != 159) [...]