Circle Clicker : Circle « Graphics « Flash / Flex / ActionScript






Circle Clicker

 
package {
  import flash.display.*;
  import flash.events.*;

  public class Main extends Sprite {
    public function Main() {
      stage.addEventListener(MouseEvent.CLICK, clickListener);
    }

    private function clickListener (e:MouseEvent):void {
      if (e.target == stage) {
        drawCircle(e.stageX, e.stageY);
      } else {
        removeChild(DisplayObject(e.target));
      }
    }

    public function drawCircle (x:int, y:int):void {
      var randomColor:int = Math.floor(Math.random(  )*0xFFFFFF);
      var randomSize:int = 10 + Math.floor(Math.random(  )*150);
      var circle:Sprite = new Sprite(  )
      circle.graphics.beginFill(randomColor, 1);
      circle.graphics.lineStyle(  );
      circle.graphics.drawEllipse(0, 0, randomSize, randomSize);
      circle.x = x-randomSize/2;
      circle.y = y-randomSize/2;
      addChild(circle);
    }
  }
}

        








Related examples in the same category

1.Create a circle shape
2.Create Rectangle and Circle
3.Fill a circle
4.Creating Custom Visual Classes