Flex 3 Example: Drawing a polygon at run time with adding and deleting points capability
I was on vacation for a couple of weeks, but I am back.
Continuing from my last example Flex 3 Example: Drawing a path at run time with adding and deleting points capabilities, I expanded the code to allow creating polygons at run time.
To create a polygon, the previous code was enhanced with graphics.endFill(); on the RedrawPath method.
I had to include additional methods to finish the polygons, as well as a method to create the last insert anchor point when finishing a polygon and more.
Below is the application to play with. To start, click on the “Add Polygon” button and then click on the stage to add points. At any time you can move any anchor (even as you are creating a polygon) to edit your polygon or any insert anchor point (light red dots) to insert additional anchor points. To end drawing a polygon click the “END” key.
Once a polygon is created in can be fully edited. Anchor points can be moved, inserted and deleted. The code is fully commented and thus I don’t go into explaining how it works in here. If you have questions post them via comments.