package { import flash.display.Sprite; [SWF(width=550, height=400, backgroundColor=0xFFFFFF)] /** * Demonstrates the drawing of basic shapes using the drawing API. */ public class graphic_flex_image_effects_01_Flex_ShapesMadeEasy extends Sprite { /** * Constructor. */ public function graphic_flex_image_effects_01_Flex_ShapesMadeEasy() { draw(); } /** * Draws rectangle and oval shapes through built-in drawing API methods. */ private function draw():void { var halfWidth:Number = stage.stageWidth/2; var halfHeight:Number = stage.stageHeight/2; var quarterWidth:Number = halfWidth/2; var quarterHeight:Number = halfHeight/2; graphics.beginFill(0xFF0000); graphics.drawCircle(quarterWidth, quarterHeight, Math.min(quarterWidth, quarterHeight)); graphics.endFill(); graphics.beginFill(0x0000FF); graphics.drawEllipse(halfWidth, 0, halfWidth, halfHeight); graphics.endFill(); graphics.beginFill(0x00FF00); graphics.drawRect(0, halfHeight, halfWidth, halfHeight); graphics.endFill(); graphics.beginFill(0xFF00FF); graphics.drawRoundRect(halfWidth, halfHeight, halfWidth, halfHeight, 70, 70); graphics.endFill(); } } }