In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: 気分転換に作り直し - particle

Circller Scratch
by ish-xxxx
// forked from ish_xxxx's 気分転換に作り直し - particle
// 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.*;
    import net.hires.debug.*;
    [SWF(width="465",height="465",frameRate="60",backgroundColor="#FFFFFF")]
    public class App extends Sprite {

        //SWF SETTING VARS/////////////////////////
        private var g:Graphics;
        ///////////////////////////////////////////

        //CONSTANTS//////////////////////////////
        private const REPEAT:uint = 10;
        ///////////////////////////////////////////

        //VARS////////////////////////////////////
        private var container:Sprite;
        private var counter:uint = 0;
        private var bmp:Bitmap, bmd:BitmapData;
                private var idol:Boolean = false, leave:Boolean = false;
        ///////////////////////////////////////////
        
        public function App() {
            init();
        }
        
        private function init() : void {
            container = addChild( new Sprite ) as Sprite;
            container.visible = false;
            bmd = new BitmapData( 465, 465, true, 0x000000 );
            bmp = addChild( new Bitmap( bmd ) ) as Bitmap;
            addChild( new Stats );
            setup();
        }
        
        private  function setup() : void {
                        stage.addEventListener( MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, false );
                        stage.addEventListener( MouseEvent.MOUSE_MOVE, onMouseMove, false, 0, false );
                        stage.addEventListener( Event.MOUSE_LEAVE, onMouseLeave, false, 0, false );
            addEventListener( Event.ENTER_FRAME, render, false, 0, false );
        }

                private function onMouseLeave( ev:Event ) : void {
                        idol = leave = true;
                }

                private function onMouseMove( ev:MouseEvent ) : void {
                        if( idol && leave ) idol = leave = false;
                }

                private function onMouseDown( ev:MouseEvent ) : void {
                        idol = !idol;
                }
        
        private function render( ev:Event ) : void {
            if( counter % 3 == 0 && !idol ) {
                for ( var i:uint = 0 ; i < REPEAT ; i++ ) {
                    var c:Circle = container.addChild( new Circle ) as Circle;
                    c.addEventListener( Circle.TRANSITION_COMPLETE , erase , false , 0 , false );
                    c.x = mouseX;
                    c.y = mouseY;
                    c.run();
                }
            }
            var mat:Matrix = new Matrix;
            bmd.draw( container, mat, null, null, null, true );
            bmd.colorTransform( bmd.rect, new ColorTransform( 1, 0.5, 1, 0.95 ) );
            counter++;
        }
        
        public function erase( ev:Event ) : void {
            var target:Circle = Circle( ev.currentTarget );
            target.removeEventListener( Circle.TRANSITION_COMPLETE , arguments.callee);
            container.removeChild( target );
            target = null;
        }
        
    }
    
}

import flash.display.*;
import flash.events.Event; 
import flash.filters.*;
import caurina.transitions.Tweener;
import caurina.transitions.properties.*;
    
internal class Circle extends Shape {

    public static const TRANSITION_COMPLETE : String = "transitioncomplete";
    private const MAX_WIDTH:uint = 15;
    private var target:DisplayObjectContainer;
    private var canvas:Graphics;

    public function Circle() : void {
        alpha = 0;
        DisplayShortcuts.init();
        CurveModifiers.init();
    }
    
    public function run() : void {
        drawCanvas();
    }
    
    private function drawCanvas() : void {
        var w:uint = Math.random()*MAX_WIDTH | 0;
        canvas = graphics;
        canvas.beginFill( Math.random()*0xFFFFFF , 1.0 );
        canvas.drawCircle( 0 , 0 , w );
        canvas.endFill();
        trans();
    }
    
    private function trans() :void {
        Tweener.addTween(
            this
            , 
            { 
                x : Math.random()*stage.stageWidth
                , 
                y : Math.random()*stage.stageHeight
                ,
                alpha : 1
                ,
                _scale : 0
                ,
                _bezier: getCurve()
                ,
                time : 2
                ,
                transition : "linear"
                ,
                onComplete : suiside
            }
        );
    }

        private function getCurve():Array {
            var n:uint = 1;
            var res:Array = new Array;
            while( n-- ) {
                res.push( {
                        x:Math.random()*465
                        ,
                        y:Math.random()*465
                    }
                );
            }
            return res;
        }
    
    private function suiside() : void {
        dispatchEvent( new Event( TRANSITION_COMPLETE ) );
    }
}