forked from: forked from: forked from: まる - 白ベース
Circller Scratch
* by ish-xxxx
// forked from no48's forked from: forked from: まる - 白ベース
// forked from siva's forked from: まる - 白ベース
// forked from ish_xxxx's まる - 白ベース
// forked from ish_xxxx's まる
/**
* Circller Scratch
* by ish-xxxx
*/
package {
import flash.display.*;
import flash.net.*;
import flash.text.*;
import flash.events.*;
import flash.geom.*;
public class App extends Sprite {
//SWF SETTING CONSTANTS//////////////////
public static const BGCOLOR:uint = 0xFFFFFF;
private const FRAMERATE:uint = 60;
private const WIDTH:uint = 465;
private const HEIGHT:uint = 465;
///////////////////////////////////////////
//SWF SETTING VARS/////////////////////////
private var CANVAS:Graphics;
///////////////////////////////////////////
//CONSTANTS//////////////////////////////
private const REPEAT:uint = 15;
///////////////////////////////////////////
//VARS////////////////////////////////////
private var counter:uint = 0;
///////////////////////////////////////////
public function App() {
//CANVAS Setting////////////////////
stage.frameRate = FRAMERATE;
CANVAS = graphics;
CANVAS.beginFill( BGCOLOR , 1.0 );
CANVAS.drawRect( 0 , 0 , WIDTH , HEIGHT );
CANVAS.endFill();
////////////////////////////////////
init();
}
private function init() : void {
setup();
}
private function setup() : void {
//
addEventListener( "enterFrame" , render );
}
private function render( ev:Event ) : void {
if( counter % 3 == 0 ) {
for ( var i:uint = 0 ; i < REPEAT ; i++ ) {
var c:Circle = new Circle( this );
c.x = mouseX;
c.y = mouseY;
addChild( c );
c.run();
}
}
counter++;
}
public function erase( target:Circle ) : void {
removeChild( target );
target = null;
}
}
}
///////////////////////////////////////////////
//Optional Classes
///////////////////////////////////////////////
import flash.display.*;
import flash.filters.*;
import caurina.transitions.Tweener;
import caurina.transitions.properties.*;
class Circle extends Shape {
private const MAX_WIDTH:uint = 30;
private var target:DisplayObjectContainer;
private var canvas:Graphics;
public function Circle( _target:DisplayObjectContainer ) : void {
target = _target;
alpha = 0;
DisplayShortcuts.init();
}
public function run() : void {
drawCanvas();
( Utils.getRandom( 10 ) | 0 ) < 4 ? filters = [ Utils.getBlur() ] : filters = [];
}
private function drawCanvas() : void {
var w:uint = Utils.getRandom( MAX_WIDTH ) | 0;
//blendMode = "add";
canvas = graphics;
canvas.beginFill( Utils.getColor() , 1.0 );
canvas.drawCircle( 0 , 0 , w );
canvas.endFill();
trans();
}
private function trans() :void {
Tweener.addTween(
this
,
{
x : Utils.getRandom( stage.stageWidth )
,
y : Utils.getRandom( stage.stageHeight )
,
alpha : 1
,
_scale : 0
,
time : 1
,
transition : "easeInOutQuad"
,
onComplete : suiside
}
);
}
private function suiside() : void {
App( target ).erase( this );
}
}
class Utils {
public function Utils() {
//Can't Create Instance
}
public static function getColor() : uint {
var ranR:String = String( uint( Math.random() * 255 | 0 ) );
var ranG:String = String( uint( Math.random() * 255 | 0 ) );
var ranB:String = String( uint( Math.random() * 255 | 0 ) );
var res:uint = uint( ranR + ranG + ranB );
return res;
}
public static function getRandom( threshold:Number ) : Number {
var res:Number;
res = Math.random() * threshold;
return res;
}
public static function getBlur() : BlurFilter {
var b:BlurFilter = new BlurFilter();
b.blurX = getRandom( 20 ) | 0;
b.blurY = getRandom( 20 ) | 0;
b.quality = BitmapFilterQuality.LOW;
return b;
}
}