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


Flash / Flex / ActionScript examples » Graphics » Circle »

 

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(00, randomSize, randomSize);
      circle.x = x-randomSize/2;
      circle.y = y-randomSize/2;
      addChild(circle);
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Graphics
» Circle