flash on 2011-5-3
/**
* Copyright bongiovi015 ( http://wonderfl.net/user/bongiovi015 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/wqG0
*/
package {
import flash.display.Sprite;
import caurina.transitions.Tweener;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import frocessing.color.ColorHSV;
public class FlashTest extends Sprite {
public function FlashTest() {
graphics.beginFill(0, 1);
graphics.drawRect(0, 0, 465, 465);
graphics.endFill();
render();
stage.addEventListener(MouseEvent.CLICK, render);
}
public function render(e:Event=null) : void {
while(numChildren >0 ) removeChildAt(0);
var color:ColorHSV = new ColorHSV(1, .3, 1);
var i : int, j:int, count:int=0;
const R : int = 20;
for(j=0; j<11; j++) {
for(i=0; i<11; i++) {
color.h = Math.random() * 360;
var circle:Circle = new Circle(2 + Math.floor(Math.random() * 10), R, color.value);
addChild(circle).alpha = 0;
circle.x = i * (R*2 + 2);
circle.y = j * (R*2 + 2);
count ++;
Tweener.addTween(circle, {time:.5, transition:"easeOutSine", alpha:1, delay:count*.01});
}
}
}
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Point;
class Circle extends Sprite {
private var __numPoints : int;
private var __color : uint;
private var __radius : Number;
private var __aPoints : Array = [];
public function Circle(numOfPoints:int, radius:Number, color:uint) : void {
__numPoints = numOfPoints;
__color = color;
__radius = radius;
__init();
mouseEnabled = false;
}
private function __init() : void {
graphics.lineStyle(1, __color, 1);
graphics.drawCircle(__radius, __radius, __radius);
var i:int = 0, j:int=0;
__aPoints = [];
var angle:Number;
for(i=0 ; i<__numPoints; i++) {
angle = Math.PI * 2 / __numPoints * i;
var p:Point = Point.polar(__radius, angle);
p = p.add(new Point(__radius, __radius));
__aPoints.push(p);
}
for(i=0;i<__aPoints.length;i++) {
for(j=i;j<__aPoints.length; j++) {
graphics.moveTo(__aPoints[i].x, __aPoints[i].y);
graphics.lineTo(__aPoints[j].x, __aPoints[j].y);
}
}
}
}