skip to Main Content

Video updated: 29 November 2018

Sections on this page:

Video 5 of the Controllers & Expressions Series:
Angie’s blushing cheeks, part 2 of 2

Starting from where I left off in the previous video, I’m going to connect the blush control to the opacity property. This will require a couple of linear( ) statements as well as an if/else expression, which is a conditional expression that I will introduce in this video.

Controllers & Expressions Series announcement graphic

Angie’s blushing cheeks,
part 2 of 2

If you missed part one, it’s here, along with the work files.

Expressions/Operators introduced:
  • if(A>=B)
  • if(A<B)
  • else
Video content:
  • 0.00 Introduction
  • 0.32 Writing the clamp expression
  • 2.55 Creating the variables for the expression
  • 5.29 Understanding the problem to solve
  • 6:06 Writing an if( ) condition
  • 7.51  Adding }else{
  • 9.33 Testing the controller & final comments
  • 10:34 End Credits

Code from the video

The code below is provided as a reference, and was copied directly from the video After Effects file. Expression fields that contained only a pick whip connection are not included.

Clamp expression for the controller handle

clamp(transform.position,[-100,0],[100,0])

Expression that connects controller handle to opacity property

DB=thisComp.layer("Blush Control Handle").effect("Default Blush Opacity")("Slider"); //DB - Default Blush opacity
BC=thisComp.layer("Blush Control Handle").transform.position[0]; //BC - Blush Control handle
if(BC>=0){
   Tr=linear(BC,0,100,DB,100);
}else{
   Tr=linear(BC,-100,0,0,DB);
}
Tr

Adding scale to your Blush Control

As mentioned in the video, your blush effect can be improved a great deal by adding an expression to the scale property. Here are the steps:

  1. Pick whip the scale property of the R Blush layer to the scale property of the  L Blush layer (just as we did with the opacity property).
  2. Option left-click (Windows: Alt left-click) the R Blush layer’s scale property stopwatch and paste the code below into the expression field.

NOTE: The code will only work if you used the same layer name for the controller handle as I did in the video. You can, of course, replace the handle layer name by deleting it in the code and using the pick whip to replace it.

BC=thisComp.layer("Blush Control Handle").transform.position[0]; //BC - Blush Control handle
if(BC>=0){
   Sc=linear(BC,0,100,[100,100],[200,200]);
}else{
   Sc=linear(BC,-100,0,[50,50],[100,100]);
}
Sc

This expression dumps the Default Blush Opacity line, as it’s not needed here, but keeps the Blush Control variable. The if/else conditional statements are based on the same code as the opacity expression. The only thing that’s changed, besides the variable name, is the last two values in each linear( ) expression.

Remember that scale, when working in two dimensions, is a two-value array, so when the Blush Control is at 0 the scale value will be [100,100]. I selected the scale [200,200] when the Blush Control is at 100, but that value can be easily adjusted to fit your own taste. Likewise, when the Blush Control is at -100 the scale value will be [50,50], which can be change.

Back To Top