 |
| |
|
| The code for creating each shape is the same apart from the line of code stating which particular shape to create. The 4th line in the example below is used to create a rectangle. |
|
 |
 |
 |
 |
|
 |
| Code: |
| 1 |
| 2 |
| 3 |
 |
| 4 |
 |
| 5 |
| 6 |
| |
|
var rectangle:Shape = new Shape();
rectangle.graphics.beginFill(0x0099CC, 1);
rectangle.graphics.lineStyle(2, 0x000000);
rectangle.graphics.drawRect(50, 150, 30,60);
rectangle.graphics.endFill();
addChild(rectangle); |
|
 |
|
| The following code will create a circle with a radius of 20 pixels |
|
 |
 |
 |
 |
|
 |
| Code: |
| 1 |
| 2 |
| 3 |
| 4 |
 |
| 5 |
| 6 |
|
var circle:Shape = new Shape();
circle.graphics.beginFill(0x990000, 1);
circle.graphics.lineStyle(2, 0x000000);
circle.graphics.drawCircle(80, 50, 20);
circle.graphics.endFill();
addChild(circle); |
|
 |
|
| The following code will create an 30x100 (widthxheight) ellipse. The "begineFill" and "endFill" function have been left out to create an elliptical outline. |
|
 |
 |
 |
 |
|
 |
| Code: |
| 1 |
| 2 |
| 3 |
 |
| 4 |
|
var ellipse:Shape = new Shape();
ellipse.graphics.lineStyle(5, 0x000000)
ellipse.graphics.drawEllipse(130,100, 30,60);
addChild(ellipse); |
|
 |
| |
|
|
|
|
|
 |