
These are conditional statements. They return a particular task like functions. However, the task depends upon on the circumstance of the Boolean operator .
What are Booleans?
A Boolean has only two values True or False | Yes or No. It works by using Comparison and Logical Operators for the particular task.
The Boolean will ask questions. Is C > D? If yes it will return the value “True” if no it will read “False”.
Let’s Practice The Boolean Operator
- Create a Text Layer
- Open the Source Text and click on the Stop Watch
- Type
3 > 5
- You are asking, is 3 greater than 5 ?
- Hit the return key and After Effects will read your expression.
- The response is False
- Then go back and type
3 < 2
- Is 3 greater than 2 ?
- The response is True
Comparison Operators
Comparison Operators are similar to mathematical symbols, but slightly different.
Operator Signs | What Does It Mean? | Example | Result |
== | Equal to each other? | 4 == 1 | false |
> | Greater than | 5 > 9 | false |
< | Less than | 6 < 9 | true |
> = | Greater than or equal | 7 > = 9 | false |
< = | Less than or equal | 8 < = 9 | true |
! = | Not Equal | 5 != 6 | true |
Basic formula
if (Condition) {Condition True: Result 1;
} else {
the Condition is False: Result 2;
}
What if you have more than one Condition?
Then you will add to conditional statements, a Logical Operator sign. It allows you to connect 2 Conditions and will result in either True or False.
Logical Operator Have 3 Types
Logical Operators | How Does It Work? | Example |
&& | And Operator: It checks both conditions to see if they are true. If both are true then it will work, but if either conditions are false it will be false. | (3 > 7) && ( 5 > 2) = False |
|| | Or Operator: Checks to see if either condition is true. It will output the task. | (1 < 0.5) || ( 2 > 1) = True, because two is greater than one. |
! | Not Operator: It inverts the statement and sets it false if it is true and vice versa. | !true = false !false = true |
A Conditional Statement with 2 Conditions
- Create at Rectangle Layer
- Open the Opacity Property and click on the Stop-Watch
- Type
r =
and use the pick whip tool to the rotation property.- It should read
r = transform.rotation;
- It should read
- Next line type the Conditional Statement
if (( r > 10 ) && (r < 50)) {100} else {0};
- It reads if the rectangle rotation is greater than 10 degrees and less than 50 degrees have the opacity property to be 100% if neither put it at 0%;