topical media & game development

talk show tell print

professional-flex-code-16-DrawShapes.ax

professional-flex-code-16-DrawShapes.ax [swf] flex


  package {
  import flash.display.Graphics;
  import flash.display.Shape;
  import flash.display.Sprite;
  
  public class @ax-professional-flex-code-16-DrawShapes extends Sprite {
    private var childCount:int = 0;
    public function @ax-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++;
    }
  }
  }


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.