Recipe 1.11. Drawing Regular Polygons


Problem

You want to draw a polygon (a closed shape made of straight lines, such as a triangle, hexagon, etc.) that has sides of equal length.

Solution

Use the PolyStar tool.

Discussion

The PolyStar tool allows you to quickly draw regular polygons with up to 32 sides. You can find the PolyStar tool nested with the Rectangle tool. There is no keyboard shortcut to the tool, so the only way to get to it is to select it from the Tools panel. Because the PolyStar tool is nested with the Rectangle tool, only one is visible at a time. Therefore, if the Rectangle tool is currently visible, click and hold the mouse on the Rectangle tool to display the pop-up menu from which you can choose the PolyStar tool. You'll know when the PolyStar tool is selected, because the icon on the Tools panel will appear as a regular hexagon instead of a rectangle.

After you've selected the PolyStar tool, you next need to select the correct options before drawing. Because the PolyStar tool allows you to draw many different types of polygons (as well as stars), you need to make the appropriate selections from the tool settings. You can access the tool settings via the Options button in the Property inspector. Clicking the Options button will open a dialog box from which you can select the number of sides. In order to draw a polygon, make sure the style is set to Polygon and not Star. The star point size applies only when drawing stars. After you've made the appropriate selections, you can click on the OK button to close the dialog box.

With the settings made, you can draw a regular polygon by clicking on the stage and dragging the mouse or stylus to the size of polygon you want. If you hold the Shift key while drawing the polygon, Flash will snap the shape to 45° increments.




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