package { import flash.display.Graphics; import flash.display.Shape; import flash.display.Sprite; public class professional_flex_code_16_DrawShapes extends Sprite { private var childCount:int = 0; public function professional_flex_code_16_DrawShapes() { doDraw( 0x336699, "circle" ); doDraw( 0x993333, "square" ); } private function doDraw( color:uint, type:String ):void { var child:Shape = new Shape(); child.graphics.beginFill( color ); child.graphics.lineStyle( 2, 0xCCCCCC ); if( type == "circle" ) child.graphics.drawCircle( 30, 40, 30); if( type == "square" ) child.graphics.drawRect( 10, 10, 60, 60 ); child.graphics.endFill(); child.x = (childCount * 65) + 10; child.y = 0; addChild(child); childCount++; } } }