• home
  • forum
  • my
  • kt
  • download
  • Drawing shapes using the Action Script code

    Author: 2009-07-14 06:22:35 From:

    In this thoroughly explained, detailed lesson, I will show you how to draw any shape using a little action script code. This lesson is created on a simple way. You just have to copy and paste my action script code to make a shape. Let's start!

    Action Script 2

    Step 1

    Create a new Flash document. Go to the Action Script Panel (F9). Copy and paste code below to get a blue rectangle.

    this.createEmptyMovieClip("rectangle_mc", 1);
    with(rectangle_mc){
    lineStyle(6, 0x003399, 100, true, "normal", "rectangle", "bevel", 1);
    moveTo(0, 0);
    lineTo(150, 0);
    lineTo(150, 70);
    lineTo(0, 70);
    lineTo(0, 0);
    _x=80;
    _y=80;
    }



    Copy and paste code below to get a red line:

    this.createEmptyMovieClip("line_mc", 1);
    with(line_mc){
    lineStyle(2, 0x990000, 100, true, "normal", "square", "miter", 1);
    moveTo(0, 0);
    lineTo(150, 0);
    _x=180;
    _y=165;
    }



    Action Script 3

    Copy and paste code below to get a green square:

    var square:Sprite = new Sprite();
    addChild(square);
    square.graphics.lineStyle(3,0x336600);
    square.graphics.beginFill(0x336600);
    square.graphics.drawRect(50,100,100,100);
    square.graphics.endFill();
    square.x = stage.stageWidth/3-square.width/3;
    square.y = stage.stageHeight/3-square.height/3;



    Copy and paste code below to get a black circle with red border:

    var myCircle:Shape = new Shape();
    myCircle.graphics.lineStyle(2, 0xff0000);
    myCircle.graphics.beginFill(0x000000);
    myCircle.graphics.drawCircle(130, 220, 80);
    addChild(myCircle);
    myCircle.graphics.endFill();



    That's it!

    Enjoy!

    discuss this topic to forum

    relation tutorial

    No information

    Category

      3D (36)
      Math Physics (18)
      3rd Party (10)
      Navigation (70)
      Actionscripting (241)
      Optimization (17)
      Animation (185)
      Projector (11)
      Audio (54)
      Special Effects (173)
      Backend (26)
      Text Effects (93)
      Drawing (34)
      Tips and Techniques (58)
      Dynamic Content (38)
      Tricks (8)
      Games (114)
      Utilities (24)
      Getting Started (99)
      Video (59)
      Interactivity (48)
      Web Design (37)

    New

    Hot