2009

Table Of Contents
4 Go to the start time.
5 With Balloon selected, choose Window > Animation Editors > Expression
Editor.
6 Enter this expression:
if (time < 2)
Balloon.scaleY = time;
This expression is an if statement. The if keyword causes the expression
to make a decision based on a comparison of two or more items. In this
case, the expression compares the value of time to the value 2.
The expression checks whether the value of time is less than two seconds.
If so, it does the assignment Balloon.scaleY = time. If time is not less than
two seconds, the assignment doesnt occur.
NOTE When you compare the value of time to a number in an expression,
Maya interprets time as seconds rather than milliseconds, minutes, or any
other unit of time. In the example, Maya interprets 2 as two seconds.
Notice how the assignment Balloon.scaleY = time has been formatted so it
appears indented under if (time < 2). Maya ignores all indentation, extra
spaces, and blank lines between statements. We used the indentation to
make the expression easier to read. You could have also written the
expression as follows:
if (time < 2) Balloon.scaleY = time;
This isnt as easy to read. Consistent, organized spacing is a good habit
to develop. This lesson attempts to show examples of good spacing style
whenever possible.
7 Click Create to compile the expression.
The ball flattens.
The expression executes when you click the Create button. Because the
animation is at frame 0, animation time is 0. Because time is less than 2,
Maya sets Balloon.scaleY equal to the value of time, which equals 0.
A scaleY value of 0 flattens the object in the Y dimension.
8 Playback the animation.
Creating a conditional expression | 575