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

flash on 2013-8-29

Get Adobe Flash player
by J.J 29 Aug 2013
    Embed
/**
 * Copyright J.J ( http://wonderfl.net/user/J.J )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/zdvG
 */

package  {

    import flash.display.BlendMode;

    import flash.filters.GlowFilter;

    import flash.geom.Point;

    import flash.display.Graphics;

    import flash.events.Event;

    import flash.display.Sprite;



    public class Gen extends Sprite {
        private var balls : Vector.<Ball>;
        private var cballs : Vector.<Ball>;
        public static var h : int;
        public static var w : int;
        private const NUM_PARTICLE : Number = 40
        private var l : Graphics;
        private var lines : Sprite;
        public function Gen() {

            stage.frameRate=60
            this.graphics.beginFill(0)
            w=stage.stageWidth,h=stage.stageHeight
            this.graphics.drawRect(0,0, w, h)
            lines=new Sprite()
            var gfltr:GlowFilter=new GlowFilter(0x0055ff)
            gfltr.blurX=gfltr.blurY=2
            lines.filters=[gfltr]
            addChild(lines)
            lines.blendMode=BlendMode.LIGHTEN
            l=lines.graphics
            balls=new Vector.<Ball>()
            cballs=new Vector.<Ball>()
            for (var i : int = 0; i < NUM_PARTICLE; i++) {
                var b:Ball=new Ball(0xffffff)
                b.x=Math.random()*w
                b.y=Math.random()*h
                b.h=h
                b.w=w
                b.vx=Math.random()*5
                b.vy=Math.random()*2
                b.g=Math.random()/5
                balls.push(b)
                cballs.push(b)
                stage.addChild(b)
            }
            addEventListener(Event.ENTER_FRAME, loop)
        }

        private function loop(event : Event) : void {
            l.clear()
            l.lineStyle(.1,0x0000ff)
            for (var i : int = 0; i < NUM_PARTICLE; i++) {
                var bi:Ball=balls[i]
                bi.render()
                bi.hited=true     

                for (var j : int = 0; j <NUM_PARTICLE ; j++) {
                    var bj:Ball=balls[j]
                    var dist:Number=Point.distance(new Point(bi.x,bi.y),new Point(bj.x,bj.y))
                    if(bj.hited==false && dist<80){
                    l.moveTo(bi.x, bi.y)
                     l.lineTo(bj.x, bj.y)

                    }
                     balls[j].hited=false
                }
            }
        }
    }

}

import flash.display.Shape;
 class Ball extends Shape{
    public var w:int,h:int
    public var vx:Number,vy:Number,g:Number=.1
    public var hited:Boolean=false
public function Ball(c:uint=0,rad:uint=5,_vx:Number=2,_vy:Number=2,_g:Number=.1):void{
    this.vy=_vy;this.vx=_vx;this.g=_g;
    this.graphics.beginFill(c)
    this.graphics.drawCircle(0, 0, rad)
    this.graphics.endFill()

}

public function render():void{
this.vy+=0
this.x+=vx
this.y+=vy
if(this.y>h) this.vy*=-1
if(this.y<0) this.vy*=-1
if(this.x>w) this.vx*=-1
if(this.x<0) this.vx*=-1
}
}