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 2009-11-15

Get Adobe Flash player
by AceDecade 15 Nov 2009
package {
    import flash.display.*;
    import flash.events.*;
    public class FlashTest extends Sprite {
        public var Levels:Array;
        public var Level:Number;
        public var Planets:Array;
        public var P:Number;
        public var seed:MovieClip;
        public var G:Number;
        public function FlashTest() {
            Levels = new Array([[120,90,30],[90,330,40],[350,260,30],[360,50,40],[290,360,50],[100,420,20]]);
            Level = 0;
            makeLevel(Levels[Level]);
            seed = new MovieClip();
            addChild(seed);
            //seed.x = Planets[0].x;
            //seed.y = Planets[0].y;
            seed.x = 170;
            seed.y = 240;
            seed.vx = 0;
            seed.vy = 0;
            seed.gx = 0;
            seed.gy = 0;
            seed.launch = false;
            seed.graphics.beginFill(0x00ff00);
            seed.graphics.drawCircle(0,0,10);
            seed.graphics.endFill();
            G = 50;
            stage.addEventListener(Event.ENTER_FRAME,main);
            stage.addEventListener(MouseEvent.MOUSE_DOWN,mousedown);
        }
        public function main(e:Event):void{
            if(seed.launch){
                seed.gx = 0;
                seed.gy = 0;
                for(var i:int=0;i<Planets.length;i++){
                    var p:MovieClip = Planets[i];
                    var X:Number = p.x-seed.x;
                    var Y:Number = p.y-seed.y;
                    var d:Number = Math.sqrt(Math.pow(X,2)+Math.pow(Y,2));
                    var a:Number = Math.atan(Y/X)*180/Math.PI;
                    if(X < 0){
                        a += 180;
                    }
                    var f:Number = G*p.radius/d;
                    seed.gx += Math.cos(a*Math.PI/180)*f;
                    seed.gy += Math.sin(a*Math.PI/180)*f;
                }
                seed.vx += seed.gx/10;
                seed.vy += seed.gy/10;
                seed.x += seed.vx;
                seed.y += seed.vy;
            }
        }
        public function mousedown(e:MouseEvent):void{
            if(!seed.launch){
                seed.launch = true;
            }
        }
        public function eraseLevel():void{
            for(var i:int=0;i<Planets.length;i++){
                removeChild(Planets[i]);
            }
        }
        public function makeLevel(A:Array):void{
            Planets = new Array();
            for(var i:int=0;i<A.length;i++){
                var p:MovieClip = new MovieClip();
                addChild(p);
                Planets.push(p);
                p.x = A[i][0];
                p.y = A[i][1];
                p.radius = A[i][2];
                p.graphics.beginFill(0x333333);
                p.graphics.drawCircle(0,0,p.radius);
                p.graphics.endFill();
            }
            p = Planets[0];
            p.graphics.beginFill(0x00ff00);
            p.graphics.drawCircle(0,0,p.radius);
            p.graphics.endFill();
            P = 0;
        }
    }
}