Draw four shapes : graphics « Graphics « Flash / Flex / ActionScript






Draw four shapes

 

package{
  import flash.display.*;
  
  public class Main extends Sprite{
    public function Main(){
        var linesA:Shape = new Shape();
        var linesB:Shape = new Shape();
        var linesC:Shape = new Shape();
        var linesD:Shape = new Shape();
        
        addChild(linesA);
        addChild(linesB);
        addChild(linesC);
        addChild(linesD);
        
        linesA.x = 100;
        linesA.y = 100;
        linesA.graphics.lineStyle(20, 0, 100, false, "none", "none", "round");
        linesA.graphics.lineTo(100, 0);
        linesA.graphics.lineTo(0, 50);
        
        linesB.x = 250;
        linesB.y = 100;
        linesB.graphics.lineStyle(20, 0, 100, false, "none", "none", "none");
        linesB.graphics.lineTo(100, 0);
        linesB.graphics.lineTo(0, 50);
        
        linesC.x = 100;
        linesC.y = 200;
        linesC.graphics.lineStyle(20, 0, 100, false, "none", "none", "miter");
        linesC.graphics.lineTo(100, 0);
        linesC.graphics.lineTo(0, 50);
        
        linesD.x = 250;
        linesD.y = 200;
        linesD.graphics.lineStyle(20, 0, 100, false, "none", "none", "miter", 10);
        linesD.graphics.lineTo(100, 0);
        linesD.graphics.lineTo(0, 50);

    }
  }
}

        








Related examples in the same category

1.Introducing the Graphics Object
2.Creating Fills
3.Drawing Circles
4.Drawing Rounded Rectangles
5.Draw lines
6.Use the graphics
7.Change line style
8.Change scaleX
9.Set Shape position
10.Draw three shapes
11.Moving the Pen without Drawing
12.Drawing a Straight Line
13.Drawing a Curve
14.Adding a Simple One-Color Fill
15.To move the drawing pen without drawing any line at all, use moveTo( ).
16.To remove all vector drawings in an object, we use the Graphics class's instance method clear( ).
17.Drawing Lines in a Graphics Object