go back

Download source file: fallingleaves.fla

Parametric equations are particularly amenable to applications in Flash that call for dynamic animation along complex paths. The file above uses a simple equation to model the leaves' motion.

One can use this approach to describe 2D and even 3D motion paths. For example, consider the vector-valued function that describes a the helix (spiraling) curve: g(t)= (R1cos(t), R2sin(t), h/2pi*t)

R1 and R2 are the horizontal and vertical radiuses. they describe the shape
of the helix if you looked at it from top-down--so if R1=R2, the top down view would be a circle.

'h' is the change in z during one revolution--it's called the pitch of thehelix. if you think of the helix curve as a spring coil, h determines how "squeezed" the coil is.

t is the angle that acts as the parameter which "animates" the curve. We use it as a counter that runs from 1 to 360 and then repeats. when you calculate the values for x and y, you'll need to
turn t into its corresponding value in radians. the code for this is "Math.PI/180*t".

In Flash, we make a function with the following code and call it from an enterFrame clip event:

1. Increase variable t by some constant increment--say, 8. If it reaches 360, reset t to one.

2. Calculate values for the three variables (x, y, and z) according to the function above--set x = R1*cosine of t, y = R2* sine of t, and z = 2 times "pi" divided by t times some constant, h.

3. modify a movie clip's _x and _y properties through some code that takes into account the x, y and z values. This might consist in some kind of scheme that modifies the _x and _y one pixel to the left and one pixel down for a one unit increase in z, and, conversely, right and up for one unit decrease in z.

© David Gillis, 2004