Drawing Vector Graphics and Shapes in ActionScript 3
A small collection of snippets to draw vector graphics and shapes in ActionScript 3.
This just draws a small red circle and adds it to the display list:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | package { import flash.display.Sprite; public class Test extends Sprite { private var ball:Sprite = new Sprite(); public function Test() { ball.graphics.beginFill(0xff0000); ball.graphics.drawCircle(0, 0, 5); ball.graphics.endFill(); ball.x = 200; ball.y = 200; addChild(ball); } } } |
This just draws a small red rectangle and adds it to the display list:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | package { import flash.display.Sprite; public class Test extends Sprite { private var rect:Sprite = new Sprite(); public function Test() { rect.graphics.beginFill(0xff0000); rect.graphics.drawRect(100, 100, 200, 200); rect.graphics.endFill(); addChild(rect); } } } |