May 21, 2011, 4:07 p.m.
posted by daemonhell
Morphing with Shape TweensAs you've seen in prior chapters, motion tweens are typically used when you want to move or manipulate a symbol over time. You can change many properties of a symbol instance during a motion tween, but by the very nature of symbols, you can't radically alter their…shapes. If a bell is ringing in your head, you're on the right track. Shapes are not instances or references to other objects, and they can be altered. Shape tweens, similar in creation to motion tweens, allow you to do so over time. Here's a simple example:
A shape tween as it appears over time
The square morphs into a circle over the duration of the tween. Any shape can morph into any other shape, provided there are nothing but shapes in the layer. However, the complexity of vectors can lead to unpredictable results. Look carefully, for example, at the morph you created. It looks as if the square is rotating as it becomes a circle. This is because Flash is doing its best to figure out how to change one vector into another, and the main anchor points of a square and a circle aren't matching up perfectly. Flash sees the main anchor points of the square in its four corners and the main anchor points of the circle at left, top, right, and bottom, as seen in Figure. It is matching the anchors of the square and circle, respectively, in pairs: upper-left to left, upper-right to top, lower-right to right, and lower-left to bottom. Therefore, the shape appears to rotate during the tween, even though it's just morphing. The main anchor points of a square and circle, as seen by Flash
Shape HintsTo improve the quality of the morph, you can add shape hints to each keyframe. Shape hints let you tell Flash precisely which points in each vector to match up during the tween. So, if you add shape hints matching the corners of the square with the secondary anchor points of the circle, the morph will no longer appear to rotate. Here's how:
Shape hints tell Flash which part of each vector to match up during the tween
The rotation that occurs when the square is morphed into the circle without shape hints is a relatively subtle distortion compared to some of the more severely confused morphs that can occur. A very simple example can be found in the 07 folder of your working directory. Compare eye_to_i_before. fla with eye_to_i_after.fla to see how shape hints can improve a morph. You can try something like this on your own by morphing one word into another. Flash can't be expected to create the morph the way you want it with so many vectors and without any additional guidance. Shape hints provide the assistance needed in these situations and can really be worth the labor it takes to add them. Using Shape Tweens in AnimationsAn oft-seen transition technique is one in which an interface appears to draw itself, line by line, until it is complete and filled with content. This can be accomplished a number of ways in Flash, but one easy way is by shape tweening lines from one size to another. You'll use this method now to draw the outline of a house:
The line starts short and gets longer, ending at frame 5. The shape tween has effectively drawn the line for you. Continue with the rest of your animation, and draw the remainder of the house outline (it will help, during the descriptions of how to draw each line, to take a look at the finished product in Figure): The finished shape tween
|
- Comment
Shape