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: NumberParticle

Get Adobe Flash player
by CoremindJP 08 Jul 2009
/**
 * Copyright CoremindJP ( http://wonderfl.net/user/CoremindJP )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/1SnS
 */

// forked from haiji505's NumberParticle
package {
    import flash.display.StageScaleMode;
    import flash.display.Sprite;
    import flash.display.MovieClip;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.filters.BlurFilter;
    import flash.events.Event;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.text.*;
    import flash.geom.*
	
    public class particleClass extends MovieClip
    {
        private var timer:Timer;
        private var numArr:Array;
        private var blur:BlurFilter;
	private var format:TextFormat;
	private	var field:TextField;

	public function particleClass() {
            numArr = [];
            blur = new BlurFilter(16, 16);
             
            format = new TextFormat();
	    format.size = 90;
	    format.font = "HGP創英角ポップ体";

	    field = new TextField();
	    field.defaultTextFormat = format;

            generateBitMap();

            timer = new Timer(5);
            timer.addEventListener(TimerEvent.TIMER, onTimer)
            timer.start()
        }
        
	private function generateBitMap():void {
            for( var i:int = 0; i < 10; i++ )
            {
		field.text = String(i);
		field.selectable = false;
                var bitMap:BitmapData = new BitmapData(
                    field.width,
                    field.height,
                    true,
                    0xFFFFFF );
		bitMap.draw(field);
                numArr[i] = bitMap;
            }
	}
		
        private function onTimer(e:TimerEvent):void {
            var pbit:Bitmap = new Bitmap(
                numArr[int(Math.random()*10)] as BitmapData,
                "auto", true )
            pbit.transform.colorTransform =
                new ColorTransform( 1, 1, 1, 0.85,
                    Math.random() * 0xFF,
                    Math.random() * 0xFF,
                    Math.random() * 0xFF );
            var rx:int = Math.random()*300;
            var ry:int = Math.random()*400;
            pbit.x = stage.mouseX+rx*Math.pow(-0.5, 1);
            pbit.y = stage.mouseY+ry*Math.pow(-0.5, 1);
            pbit.scaleX = 1.75;
            pbit.scaleY = 1.75;
            pbit.filters = [blur];
            pbit.addEventListener(Event.ENTER_FRAME, playParticle);
            addChild( pbit );
        }
		
	private function playParticle(e:Event):void
        {
	    var pObject:Bitmap = e.target as Bitmap;
            var _num:Number = 1;
            stage.mouseX > 230 ?
                pObject.x +=-5:
                pObject.x += 5;
            stage.mouseY > 230 ?
                pObject.y +=-5:
                pObject.y += 5;
	    pObject.scaleX -= 0.05;
	    pObject.scaleY -= 0.05;
	    pObject.alpha -= 0.02;
            pObject.scaleX < 1 ?
                pObject.filters = []:
                pObject.rotation += Math.random() * 180;
            if( pObject.scaleX <= 0 ) {
		pObject.removeEventListener(Event.ENTER_FRAME, playParticle);
		removeChild(pObject);
	    }
	}
    }
    
}