/** * Circller Scratch * by ish-xxxx */ package { import flash.display.*; import flash.net.*; import flash.text.*; import flash.events.*; import flash.geom.*; import net.hires.debug.*; public class App extends Sprite { //SWF SETTING CONSTANTS////////////////// public static const BGCOLOR:uint = 0x020202; 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 = 20; /////////////////////////////////////////// //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(); c.addEventListener( Circle.TRANSITION_COMPLETE , erase , false , 0 , false ); c.x = mouseX; c.y = mouseY; addChild( c ); c.run(); } } counter++; } public function erase( ev:Event ) : void { var target:Circle = Circle( ev.currentTarget ); target.removeEventListener( Circle.TRANSITION_COMPLETE , erase ); removeChild( target ); target = null; } } } /////////////////////////////////////////////// //Optional Classes /////////////////////////////////////////////// import flash.display.*; import flash.events.*; import flash.filters.*; import caurina.transitions.Tweener; import caurina.transitions.properties.*; class Circle extends Shape { public static const TRANSITION_COMPLETE : String = "transitioncomplete"; private const MAX_WIDTH:uint = 30; private var target:DisplayObjectContainer; private var canvas:Graphics; public function Circle() : void { 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; 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 { dispatchEvent( new Event( TRANSITION_COMPLETE ) ); } } 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 = b.blurY = getRandom( 20 ) | 0; b.quality = BitmapFilterQuality.LOW; return b; } } まる - 黒ベース