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: forked from: particle

@author sph62

[SWF(backgroundColor="0xFFFFFF",width="800",height="800",frameRate="30")]
Get Adobe Flash player
by h_sakurai 17 Jan 2009
// forked from nayu's forked from: particle
// forked from sph62's particle
package  {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
        
        /**
         *
         * @author sph62
         */

	//[SWF(backgroundColor="0xFFFFFF",width="800",height="800",frameRate="30")]
	public class Main extends Sprite {
		private var particles:Array;
		private var numParticles:uint = 50;
		private var minDist:Number = 100;
		private var springAmount:Number =  .001;
                public var human:Ship;
		public function Main() {
                    main = this;
                    human=new Ship();
                    this.x = 230;
                    this.y = 230;
		    addEventListener(Event.ENTER_FRAME, onEnterFrame);	
		}

		private function onEnterFrame(event:Event):void {
                        human.move();
		}
	}
}
var springs:Vector.<Spring> = new Vector.<Spring>;
var balls:Vector.<Ball> = new Vector.<Ball>;
class Ship {
    public var head:Ball=new Ball();
    public var neck:Ball=new Ball();
    public var lkata:Ball=new Ball();
    public var rkata:Ball=new Ball();
    public var lhiji:Ball=new Ball();
    public var rhiji:Ball=new Ball();
    public var lte:Ball=new Ball();
    public var rte:Ball=new Ball();
    public var mune:Ball=new Ball();
    public var koshi:Ball=new Ball();
    public var lkoshi:Ball=new Ball();
    public var rkoshi:Ball=new Ball();
    public var lhiza:Ball=new Ball();
    public var rhiza:Ball=new Ball();
    public var lashi:Ball=new Ball();
    public var rashi:Ball=new Ball();
    function Ship() {
        new Spring(head,neck, 10);
        new Spring(neck,lkata, 30);
        new Spring(neck,rkata, 30);
        new Spring(lkata,lhiji, 30);
        new Spring(rkata,rhiji, 30);
        new Spring(lhiji,lte, 30);
        new Spring(rhiji,rte, 30);
        new Spring(lkata,rkata, 80);
        new Spring(neck,mune, 10);
        new Spring(lkata,mune, 50);
        new Spring(rkata,mune, 50);
        new Spring(mune,koshi, 30);
        new Spring(koshi,rkoshi, 30);
        new Spring(koshi,lkoshi, 30);
        new Spring(lkoshi,rkoshi, 50);
        new Spring(lkoshi,lhiza, 80);
        new Spring(rkoshi,rhiza, 80);
        new Spring(lhiza,lashi, 80);
        new Spring(rhiza,rashi, 80);
    }
    public function move():void {
        for(var i:int=0;i<10;i++){
            head.ay -= 2;//balls.length/2;
            //neck.ay -= balls.length/2;
            head.az += 5;
            lashi.ay ++; rashi.ay++;
            mune.z=00;
            lte.az -= 1;
            lte.ax += 1; rte.ax -= 1;
            lkata.ax += 1; rkata.ax -= 1;
            rte.az += 2;
            lashi.az -= 1; lashi.ax += 1; rashi.ax -= 1;
            lkoshi.ax += 1; rkoshi.ax -= 1;
            rashi.az -= 1;
            for each (var ss:Spring in springs) { ss.move();}
            for each (var b:Ball in balls) { b.move();}
        }
    }
}
var main:Main;
import flash.display.Sprite;
class Spring {
    public var a:Ball;
    public var b:Ball;
    public var length:Number;
    public var len2:Number;
    public var k:Number=0.2;
    function Spring(a:Ball,b:Ball,len:Number){
        this.a = a; this.b = b; length = len/10;
        springs.push(this);
    }
    public function move():void {
        var nx:Number=a.x-b.x;
        var ny:Number=a.y-b.y;
        var nz:Number=a.z-b.z;
        var len:Number = Math.sqrt(nx*nx+ny*ny+nz*nz);
        var f:Number=len-length;
        var ax:Number,ay:Number,az:Number;
        if(len==0) {
            ax = Math.random()-.5;
            ay = Math.random()-.5;
            az = Math.random()-.5;
        } else {
            ax = -nx/len*f*k;
            ay = -ny/len*f*k;
            az = -nz/len*f*k;
        }
        a.ax +=  ax; a.ay +=  ay; a.az += az;
        b.ax += -ax; b.ay += -ay; b.az -= az;
    }
}
class Ball extends Sprite {
	public var _radius:Number;
	public var _color:uint;
	public var _alpha:Number;

	public var mass:Number = 0;
	
	public var vx:Number = 0;
	public var vy:Number = 0;
	public var vz:Number = 0;
	public var ax:Number = 0;
	public var ay:Number = 0;
	public var az:Number = 0;
        public var drag:Boolean = false;
	public function Ball(radius:Number = 5, color:uint = 0x0066FF, alpha:Number = .3 ) {
		this._radius = radius;
		this._color = color;
		this._alpha = alpha;
		this.mass = radius * 5;
		graphics.beginFill(_color, _alpha);
		graphics.drawCircle(0, 0, _radius);
		graphics.endFill();
		graphics.beginFill(_color, _alpha);
		graphics.drawCircle(0, 0, _radius*2);
		graphics.endFill();
            balls.push(this);
            main.addChild(this);
            addEventListener("mouseDown",function():void{
                startDrag(); drag=true;
            });
            addEventListener("mouseUp",function():void{
                stopDrag(); drag=false;
            });
	}
        public function move():void {
            if(!drag){
                if(y>230){az-=1; ay-=15}
                //ay+=1;
                vx+=ax; vy+=ay; vz+=az;
                x+=vx;y+=vy;z+=vz;
            }
                vx*=0.7;vy*=0.7;vz*=0.7;
                ax=0;ay=0;az=0;
        }
}