The SWF::Morph Module
A Morph is an object that encapsulates all the different
transition states that represent the transformation of one shape into
another. To use a Morph, you set an initial state and a final state
(both SWF::Shape objects). As the first shape is transformed into the
second, all of the original shape’s attributes (color, rotation, etc.)
are gradually adjusted to match those of the final state. Once the
Morph is placed within a frame, you can set the state of the Morph to
any of the infinite number of transitional states between the two
extreme shapes using the setRatio(
) method. A value of .5 displays an item that is halfway
morphed between the starting and ending state. In the following
example, the Morph changes from a square to a star in 10 frames, then
changes back to a square in another 10 frames.
Both the initial and final shapes must contain an equal number of points. If the two states are defined by shapes with different numbers of points, you’ll get inconsistent results in the final movie (typically random lines and noise).
In Example 9-4, a red square morphs into a blue eight-pointed star over the course of 10 frames, then morphs back into a square. Figure 9-6 shows a few of the stages.

#!/usr/bin/perl -w # # Example 9-4. Morphing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access