How to draw polygon in Flash MX

Source: Internet
Author: User
Tags copy cos sin

First, with transform panel

We take positive Pentagon as an example

1, create a new file, in the scene to draw a straight line, press F8 into the film, the center as the upper left corner, as shown in Figure 1

Figure 1: The center is set in the upper left corner

2, select the line, press Ctrl+t to pull out the transform panel, and in the Rotate box to enter 72 (360/5), the angle of calculation is 360 degrees divided by the number of edges. As shown in Figure 2

Figure 2:transform Panel

3, press the copy of the Panel and apply Transform button 4 times, you can copy out of the ring arranged four lines

4, press CTRL + A to select all the straight line, according to Ctrl+b scattered, in turn, the end of the line connection, remove the excess line is completed. As shown in Figure 3.

Figure 3: Positive Pentagon

Second, with AS

The interface, as shown in the following illustration, is concise, with two input text boxes and a button

You just enter the number of edges and sizes in the text box, press the OK button, you can draw the polygon you want, the following we will make a step-by-step.

1, start flash, press CTRL + N to create a new file, scene size and background set reasonable can be, press Ctrl+s save, file name is polygon.

2, press the T key to select the Text tool, and open the property panel, the following figure to select the input text,

Drag a text box in the upper-left corner of the scene, as the number of sides of the polygon, or enter BB in the Var bar in the property panel, and take a variable name for the text box to make it easier to call the program later. Using the same method to make another text box, named AA, as the size of the polygon.

3. Draw a small square in the scene and select it, press F8 to convert to a button,

4, and finally add as for the button, as follows:

Train of thought: divide a circle into n equal parts, connect these dots, such as the right diagram how to draw Pentagon

On (release)//mouse is released by executing the following statement {   daxiao=aa;   Gets the size of the polygon from the text box entered, in pixels   Bianshu = BB;   Gets the number of edges, integers, starting from 3, to infinity, and n polygons are rounded   jiaodu = 360/bianshu;   Get each equal angle for   (n=1 n<=bianshu; n++)   //for loop, by Bianshu to control the number of loops, that is, the number of polygons to draw   {    a = daxiao* Math.Cos (n*jiaodu*math.pi/180); b = Daxiao*math.sin (n*jiaodu*math.pi/180); The coordinates of the starting point are calculated with trigonometric functions C = Daxiao*math.cos ((n+1) *jiaodu*math.pi/180); D = Daxiao*math.sin ((n+1) *jiaodu*math.pi/180); The coordinate createemptymovieclip ("Xian", N) of the endpoint are calculated. Create an empty movie xian,n as hierarchy with (Xian) {   LineStyle (2, 0xff0000, MB);   Define the size, color, transparency     moveTo (a+300, b+200) of the line,///define the coordinates of the starting point of the drawing line, (300,200) is the center of the Polygon LineTo (c+300, d+200);//define the coordinates of the end of the drawing Line   }} }


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.