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

Home
Flash / Flex / ActionScript
1.Animation
2.Array
3.Class
4.Data Type
5.Development
6.Function
7.Graphics
8.Language
9.Network
10.Regular Expressions
11.Statement
12.String
13.TextField
14.XML
Flash / Flex / ActionScript » 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);
    }
  }
}

        
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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.