The following code draws basic shapes, colours them and positions them on the stage. Similar to using Java Swing, when you create a new GUI element, it must be added.

Compared to Java, the variable declaration is looser than Java which requires the programmer to declare the data type for a variable (int, long, char etc). ActionScript3, like
JavaScript, declares variables with var instead.

As you can see, each new instance of class Sprite has a unique name (square, rect, circle). These can be whatever you like. I commented the first shape for your reference, followed with two more shapes.

//This import was done automatically when I created the first Sprite

import flash.display.Sprite;

var square:Sprite = new Sprite();
addChild(square);

/*first lineStyle digit controls thickness of the
line the second value is the line colour.*/

square.graphics.lineStyle(2,0×000000);

//the fill colour

square.graphics.beginFill(0x555555);

//create the shape dimensions

square.graphics.drawRect(0,0,150,100);

//end the fill

square.graphics.endFill();

/*position on stage, see following objects for other
versions of this*/

square.x = stage.stageWidth/2-square.width/2;
square.y = stage.stageHeight/2-square.height/2;

 

var rect:Sprite = new Sprite();
addChild(rect);
rect.graphics.lineStyle(5,0x0000ff);
rect.graphics.beginFill(0x556655);
rect.graphics.drawRect(10,100,50,90);
rect.graphics.endFill();
rect.x = 10;
rect.y = -70;

 

var circle:Sprite = new Sprite();
addChild(circle);
circle.graphics.beginFill(0x898fff,5);
circle.graphics.drawCircle(10,10,60);
circle.graphics.endFill();
circle.x = 100;
circle.y = 200;

Thanks to http://www.actionscript.org for fantastic tutorials and code commenting!