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

Dispertion

Get Adobe Flash player
by Abarrow 03 Aug 2015
    Embed
package {
    import flash.display.Sprite;
    import flash.display.Graphics;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Point;
    [SWF(frameRate=120)]
    public class FlashTest extends Sprite {
        private var selectedIndex:uint=0;
        private var selected:Boolean=false;
        private var mox:int=0;
        private var moy:int=0;
        private var points:Vector.<VPoint>=new Vector.<VPoint>();
        public function FlashTest() {
            
            for(var n:int=0;n<300;n++){
                points.push(new VPoint(Math.random()*465, Math.random()*465, 0, 0));
            }

            addEventListener(Event.ENTER_FRAME, enter);
            stage.addEventListener(MouseEvent.MOUSE_DOWN, downer);
            stage.addEventListener(MouseEvent.MOUSE_UP, upper);
            stage.addEventListener(MouseEvent.MOUSE_MOVE, mover);
        }
        private function downer(event:MouseEvent):void{
            var point:VPoint;
            var dx:Number;
            var dy:Number;
            var dis:Number;
            for(var n:int=0;n<points.length;n++){
                point=points[n];
                dx=point.x-mox;
                dy=point.y-moy;
                dis=Math.sqrt(dx*dx+dy*dy);
                if(dis<3){
                    selectedIndex=n;
                    selected=true;
                    break;
                }
            }
        }
        private function upper(event:MouseEvent):void{
            selected=false;
        }
        private function mover(event:MouseEvent):void{
            mox=event.stageX;
            moy=event.stageY;
        }
        private function enter(event:Event):void{
            if(selected){
                points[selectedIndex].x=mox;
                points[selectedIndex].y=moy;
            }
            graphics.clear();
            graphics.lineStyle(1, 0x000000);
            var point:VPoint;
            var pointu:VPoint;
            var dx:Number;
            var dy:Number;
            var dis:Number;
            for(var n:int=0;n<points.length;n++){
                point=points[n];
                if(!(n==selectedIndex&&selected)){
                    for(var en:int=0;en<points.length;en++){
                        if(n!=en){
                            pointu=points[en];
                            dx=point.x-pointu.x;
                            dy=point.y-pointu.y;
                            dis=Math.sqrt(dx*dx+dy*dy);
                            if (dis < 60) {
                                point.vx+=dx*10/dis/dis;
                                point.vy+=dy*10/dis/dis;
                            }
                        }
                    }
                }
                point.x+=point.vx;
                point.y+=point.vy;
                point.vx*=0.2;
                point.vy*=0.2;
                //render
                graphics.beginFill(0);
                graphics.drawCircle(point.x, point.y, 2);
                graphics.endFill();
            }
        }
    }
}
import flash.geom.Point;
class VPoint extends Point{
    public var vx:Number;
    public var vy:Number;
    public function VPoint(ex:Number, ey:Number, vex:Number, vey:Number){
        super(ex, ey);
        vx=vex;
        vy=vey;
    }
}