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

temp

Get Adobe Flash player
by jokehn9 13 Jun 2012
/**
 * Copyright jokehn9 ( http://wonderfl.net/user/jokehn9 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6c9Y
 */

package {
    import flash.filters.BlurFilter;
    import flash.geom.Point;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.display.Shape;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        
        private var shape:Shape;
        private var arr:Array = [];
        private const num:int = 15;
        private var canvas:BitmapData = new BitmapData(465,465,true,0x0);
            
        public function FlashTest() {
            // write as3 code here..
            shape = new Shape();
            addChild(new Bitmap(canvas));
            var p:Particle = new Particle();
           
            for(var i:int = 0;i<num; i++) {
                arr[i] = new Particle;
                arr[i].x = arr[i].prevx = Math.random() * 465;
                arr[i].y = arr[i].prevy = Math.random() * 465;
            }

            addEventListener("enterFrame",ff);
            stage.addEventListener("mouseDown",boom);
            

            
        }
        private function ff(e:Event):void {
            //움직인다.
            var p:Particle;
            var dx:Number,dy:Number;
            var d:Number = 0;
            
         
            
            for(var i:int = 0; i<num;i++) {
                
                p = arr[i];
                p.disx = p.targetX - p.nowX;
                p.disy = p.targetY - p.nowY;
                p.vx += p.disx / 50;
                p.vy += p.disy / 50;
                p.nowX += p.vx;
                p.nowY += p.vy;
                dx = p.nowX- p.x;
                dy = p.nowY - p.y;
                d = Math.sqrt(dx*dx + dy*dy);
                p.speedX += dx * 3 / d;
                p.speedY += dy * 3/ d;
                p.speedD = Math.sqrt(p.speedX*p.speedX + p.speedY * p.speedY);
                p.speedX = p.speedX ;
                p.speedY = p.speedY ;
               

                p.ds = d;
                p.x += p.speedX;
                p.y += p.speedY;
            }

            //그린다
                shape.graphics.clear();
                canvas.draw(shape);
                //
                shape.graphics.lineStyle(1,0x0);
                for(i = 0; i< num;i++) {
                    shape.graphics.lineStyle(Math.abs(arr[i].speedD)*10,(arr[i].color),1);
                    shape.graphics.moveTo(arr[i].prevx,arr[i].prevy);
                    shape.graphics.lineTo(arr[i].x,arr[i].y);
                    arr[i].prevx = arr[i].x
                    arr[i].prevy = arr[i].y
                }
                canvas.draw(shape,shape.transform.matrix,null);
               // canvas.applyFilter(canvas,canvas.rect,new Point, new BlurFilter(12,12,1));
                

        }
        
        private function boom(e:Event):void {
            var dx:Number, dy:Number = 0;
            var mi:int = 0;
            for(var i:int = 0; i<num;i++) {
                    if(Math.random() > 0.5) {
                        mi = 1;
                    }
                    else {
                        mi = -1;
                    }


                    arr[i].speedX =  -60 * Math.random() + 30;
                    arr[i].speedY =  arr[i].speedX * mi;
                
            }

        }

    }
}

class Particle {
    public var x:Number = 0;
    public var y:Number = 0;
    public var speedX:Number = 0;
    public var speedY:Number = 0;
    public var prevx:Number = 0;
    public var prevy:Number = 0;
    public var ds:Number = 0;
    public var color:uint = 0xffffff * Math.random();
    public var speedD:Number = 0;
    public var targetX:Number = Math.random() * 100 + 100;
    public var targetY:Number = Math.random() * 100 + 100;
    public var disx:Number = 0;
    public var disy:Number = 0;
    public var nowX:Number = Math.random() * 465;
    public var nowY:Number = Math.random() * 465;
    public var vx:Number = 0;
    public var vy:Number = 0;
 
}