Masterstudy #04: Vucko’s From Nothing to Something

Note

Below are the expressions used in the tutorial for troubleshooting and comparison purposes. I honestly would prefer you to type out the code yourself because you learn better that way. But hey, only if you want to!

Generate random number

//apply to slider control "choice_bg" in null layer "controls"
// generates a random number at every single frame

seed = 1;
seedRandom(seed,false);
Math.ceil(random(8));

//apply to slider control "choice_type" in null layer "controls"
// generates a DIFFERENT random number at every single frame

seed = 1;
seedRandom(seed,false);

choice_bg = effect("choice_bg")("Slider");
choice_type = Math.ceil(random(8));

while(choice_type==choice_bg){
	choice_type = Math.ceil(random(8));
}
choice_type;

Get random color control

// apply to Fill for background layer
choice = thisComp.layer("controls").effect("choice_bg")("Slider")
myString = "Color Control " + choice;
thisComp.layer("controls").effect(myString)("Color");

// apply to Fill for background layer
choice = thisComp.layer("controls").effect("choice_text")("Slider")
myString = "Color Control " + choice;
thisComp.layer("controls").effect(myString)("Color");

Random color changing layers

// apply this to your Time Remap property of your Sprite render 
c= thisComp.layer("controls");
seed = c.effect("seed")("Slider");
segMin = .5; //minimum segment duration
segMax = .8; //maximum segment duration
flickerDurMin = 1;
flickerDurMax = 5;

end = 0;
j = 0;

while ( time >= end){
  j += 1;
  seedRandom(j,true);
  start = end;
  end += random(segMin,segMax);
}

flickerDur = random(flickerDurMin,flickerDurMax);

if (time > end - flickerDur){
  seedRandom(j+69+seed,true);
  random(outPoint);
}else{
   seedRandom(j+seed,true);
  random(outPoint);
}

Random y-position sliding down

//Apply this to y-position of a sprite layer

aux = thisComp.layer("aux");
seedRandom(aux.effect("seed")("Slider"),true);
delay = random(aux.effect("delay")("Slider"));
aux.transform.yPosition.valueAtTime(time+delay)

Random x-position “opening”

s = thisComp.layer("controls").effect("x")("Slider")
myIndex = index-thisComp.layer("controls").index;
if(myIndex<thisComp.layer("controls").effect("choice")("Slider")){value-s} 	else value+s

Random x-position offset (staggering)

// random x-position offset
c = thisComp.layer("controls");
seed = c.effect("seed_pos")("Slider");
seedRandom(seed,true);

x = r  andom(c.effect("x")("Slider"));
value+x