Recipe 1.14. Building Complex Shapes from Simple Shapes


Problem

You want to create a complex shape for which Flash doesn't have a specific tool.

Solution

Use Flash's intersect, punch, crop, slice, and union behaviors strategically to create the shape in multiple steps.

Discussion

Flash has two drawing models merge and object. Making complex shapes is possible using either drawing model. Which approach you take is a matter of preference, as is the type of shape you want to make. When you select a tool that supports the object drawing model (e. g., the Oval or Rectangle tools), a small Object Drawing button appears in the Options section of the Tools panel. The button (with a circular icon) enables you to toggle between the merge (default, deselected state) and object (selected state) drawing models.

When you draw on the stage using the merge drawing model, elements drawn in the same layer and frame that overlap will interact with one another by slicing, merging, and/or punching. Flash's auto-slice, auto-punch, and auto-union behaviors are unusual among vector applications. In most drawing applications, slicing, union, and punch are available, but they never happen automatically. All too often, Flash users inadvertently utilize one of the features, with Undo as the only recourse. However, you can and should use Flash's behavior strategically to create shapes that would otherwise be difficult to create.

When you place an ungrouped shape over another and deselect both shapes, Flash will automatically apply a slice, punch, or union behavior, depending on several factors. If the shapes have no outlines and are the same color, the union behavior is applied such that the two shapes merge into one shape. If the top shape has an outline or is a different color than the bottom shape, the top shape will punch out the bottom. A line that crosses another line or shape slices the line or shape it crosses.

For many shapes, the slicing, union, and punch behaviors are more efficient than using the Pen tool to plot several points, and then painstakingly modifying the Bézier curves with the Subselection tool. Figure 1-1 shows two unique shapes that were created by punching and merging shapes. The cloud formation at the top was created by laying one oval above another, all of the same color. After the overall shape was created, a linear gradient was applied to give it visual interest. The comb shape at the bottom was created by drawing a basic outline with the Pen tool, and then punching it with a simple spike shape.

When drawing, look at your subject not merely as a collection of outlines, but also as composites of simple shapes (both positive and, in the case of the comb spikes, negative).

You can prevent the slicing, punching, and cropping behaviors of overlapping elements in several ways. You can group elements (Modify Group).You can place the elements in different layers. Or you can use the object drawing model when drawing the shapes.

When you use the object drawing model the auto-punch, auto-slice, and auto-union behaviors are disabled for those shapes. However, you can still combine elements to make more complex shapes. To do so, select the objects you want to combine, then modify the Union, Intersect, Punch, and Crop options from the Modify Combine Objects menu. The Union and Punch options work like the auto-union and autopunch features. The Intersection option combines the two objects into a new shape that is formed by the area in which the two objects intersect. The Crop option crops the bottom shape using the top shape as the mask.

Figure 1-1. Create complex shapes overlapping simple shapes, using Flash's auto-union (top) and auto-punch (bottom) behaviors


If you've drawn a shape using the object drawing model and you'd like to utilize the auto-punch, auto-slice, and auto-union features, you can still do so. You need only to select the shape and ungroup it (Modify Ungroup).After youve ungrouped an object, it behaves just like a shape drawn with the merge drawing model.

See Also

Recipe 1.31, Recipe 1.33




Flash 8 Cookbook
Flash 8 Cookbook (Cookbooks (OReilly))
ISBN: 0596102402
EAN: 2147483647
Year: 2007
Pages: 336
Authors: Joey Lott

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net