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

Planet Orbitor v1.17

Code: By Tyler Seitz, http://twitter.com/tylerseitz <- Follow Me On Twitter
Special Thanks UnknownGuardian & BraydenBlack from the ProFusion development team over at http://profusiongames.com/ for helping me

Left & Right to rotate
Up & Down to increase or decrease the Planet Orbitor's Distance from the planet
Space to fire bullets

Note: I am going to be adding more things to it, so at times it may be broken.

Current Version 1.17 // After much optimising i managed to get the particle effect working decently, however i still notice lag although others report there to be none.
Get Adobe Flash player
by tylerseitz 17 Aug 2011
/**
 * Copyright tylerseitz ( http://wonderfl.net/user/tylerseitz )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/s2d4
 */

//Code: By Tyler Seitz, http://twitter.com/tylerseitz <- Follow Me On Twitter
//Special Thanks UnknownGuardian & BraydenBlack from the ProFusion development team over at http://profusiongames.com/ for helping me
package {
    import flash.display.*;
    import flash.events.*;
    import flash.ui.*;
    
    [SWF(width="400", height="400", backgroundColor = 0x000000, frameRate="30")]
    
    public class Main extends Sprite {
        public var player:Player = new Player();
        public var planet:Sprite = new Planet();
        
        public var speed:Number = 0.03;
        public var angle:Number = 0;
        public var distance:Number = 100;
        public var radius:Number = planet.width / 2 + distance;
        
        public var keyLeft:Boolean = false;
        public var keyRight:Boolean = false;
        public var keyUp:Boolean = false;
        public var keyDown:Boolean = false;
        public var keySpace:Boolean = false;
        
        public var fireRate:Number = 0;

        public function Main() {
            //constructor code
            addChild(planet);
            planet.x = 200;
            planet.y = 200;
            addChild(player);
            player.x = planet.x + radius;
            player.y = 200;
            player.rotation = (Math.atan2(player.y-planet.y, player.x-planet.x) * 180 / Math.PI) - 90;
            stage.addEventListener(KeyboardEvent.KEY_DOWN, playerRotateDown);
            stage.addEventListener(KeyboardEvent.KEY_UP, playerRotateUp);
            addEventListener(Event.ENTER_FRAME, enterFrame);
        }
       public function playerRotateDown(e:KeyboardEvent):void{
           //Left & Right or A & D
           if(e.keyCode == 65 || e.keyCode == 37){
               keyLeft = true;
           }else if(e.keyCode == 68 || e.keyCode == 39){
               keyRight = true;
           }
           //Up & Down or W & S
           if(e.keyCode == 87 || e.keyCode == 38){
               keyUp = true;
           }else if(e.keyCode == 83 || e.keyCode == 40){
               keyDown = true;
           }
           //Space
           if(e.keyCode == 32){
               keySpace = true;
           }
       }
       public function playerRotateUp(e:KeyboardEvent):void{
           //Left & Right or A & D
           if(e.keyCode == 65 || e.keyCode == 37){
               keyLeft = false;
           }else if(e.keyCode == 68 || e.keyCode == 39){
               keyRight = false;
           }
           //Up & Down or W & S
           if(e.keyCode == 87 || e.keyCode == 38){
               keyUp = false;
           }else if(e.keyCode == 83 || e.keyCode == 40){
               keyDown = false;
           }
           //Space
           if(e.keyCode == 32){
               keySpace = false;
           }
       }
       public function enterFrame(e:Event):void{
           fireRate += 1;
           if(keyLeft == true && keyRight == false){
               //clockwise rotation
               player.x = planet.x + Math.cos(angle) * radius;
               player.y = planet.y + Math.sin(angle) * radius;
               angle += speed;
               player.rotation = (Math.atan2(player.y-planet.y, player.x-planet.x) * 180 / Math.PI) - 90;
           }
           if(keyRight == true && keyLeft == false){
               //counter clockwise rotation
               player.x = planet.x + Math.cos(angle) * radius;
               player.y = planet.y + Math.sin(angle) * radius;
               angle -= speed;
               player.rotation = (Math.atan2(player.y-planet.y, player.x-planet.x) * 180 / Math.PI) - 90;
           }
           if(keyUp == true && keyDown == false){
               //moves towards planet
               if(player.x >= planet.x + 75 || player.x <= planet.x - 75 || player.y >= planet.y + 75 || player.y <= planet.y - 75 ){
                   distance -= 2;
                   radius = planet.width / 2 + distance;
                   player.x = planet.x + Math.cos(angle) * radius;
                   player.y = planet.y + Math.sin(angle) * radius;
               }
           }
           if(keyDown == true && keyUp == false){
               //moves away from planet
               if(player.x <= planet.x + 150 && player.x >= planet.x - 150 && player.y <= planet.y + 150 && player.y >= planet.y - 150 ){
                   distance += 2;
                   radius = planet.width / 2 + distance;
                   player.x = planet.x + Math.cos(angle) * radius;
                   player.y = planet.y + Math.sin(angle) * radius;
               }
           }
           if(fireRate >= 4){
               if(keySpace == true){
                   //attach bullet near the player
                   var bullet:Bullet = new Bullet();
                   stage.addChild(bullet);
                   bullet.x = player.x;
                   bullet.y = player.y;
                   bullet.rotation = (Math.atan2(player.y-planet.y, player.x-planet.x) * 180 / Math.PI) - 90;
                   fireRate = 0;
               }
           }
       }
    }
}

import flash.display.*;
import flash.events.*;

class Player extends Sprite{
    public var playerShape:Shape = new Shape();
    public function Player(){
        addChild(playerShape);
        playerShape.graphics.lineStyle(1, 0xffffff); 
        playerShape.graphics.beginFill(0xffffff, 1);
        playerShape.graphics.lineTo(0, 0);
        playerShape.graphics.lineTo(8, 10);
        playerShape.graphics.lineTo(-8, 10);
        playerShape.graphics.endFill();
    }
}

import flash.display.*;
import flash.events.*;

class Planet extends Sprite{
    public var planetShape:Shape = new Shape();
    static public var planetX:Number;
    static public var planetY:Number;
    public function Planet(){
        addChild(planetShape);
        planetShape.graphics.beginFill(0xffffff);
        planetShape.graphics.drawCircle(0,0,50);
        planetShape.graphics.endFill();
        addEventListener(Event.ENTER_FRAME, enterFrame);
    }
    public function enterFrame(e:Event):void{
        planetX = this.x;
        planetY = this.y;
    }
}

import flash.display.*;
import flash.events.*;

class Bullet extends Sprite{
    public var bulletShape:Shape = new Shape();
    public var bulletSpeed:Number = 6;
    public function Bullet(){
        addChild(bulletShape);
        bulletShape.graphics.beginFill(0xffffff);
        bulletShape.graphics.drawRect(-1.5, -2.5, 3, 5);
        bulletShape.graphics.endFill();
        addEventListener(Event.ENTER_FRAME, enterFrame);
    }
    public function enterFrame(e:Event):void{
       var dx:Number = Planet.planetX-this.x;
       var dy:Number = Planet.planetY-this.y;
       var dr:Number = Math.sqrt(dx * dx + dy * dy);
       if(dr < 50 + this.width/2) {
           var particles:Number = int(Math.random() * (6 - 3)) + 3;
           for(var i:int=0; i < particles; i++){
               var particle:Particle = new Particle();
               stage.addChild(particle);
               particle.x = this.x;
               particle.y = this.y;
           }
           stage.removeChild(this);
       }
       this.x += bulletSpeed * Math.sin(this.rotation * Math.PI / 180);  
       this.y += bulletSpeed * -Math.cos(this.rotation * Math.PI / 180);
    } 
}

import flash.display.*;
import flash.events.*;

class Particle extends Sprite{
    public var life:Number;
    public var radius:Number;
    public var xSpeed:Number;
    public var ySpeed:Number;
    public var particleShape:Shape = new Shape();
    public function Particle(){
        life = 20;
        radius = 20
        
        xSpeed = Math.random() * 4 - 2;            
        ySpeed = Math.random() * 4 - 2;
        addChild(particleShape);
        particleShape.graphics.beginFill(0xffffff);
        particleShape.graphics.drawRect(-1, -1, 2, 2);
        particleShape.graphics.endFill();
        addEventListener(Event.ENTER_FRAME, enterFrame);
    }
    public function enterFrame(e:Event):void{
        life-= 1;
        this.x += xSpeed;
        this.y += ySpeed;
        this.alpha = life / radius;
        if(life <= 0){
            removeEventListener(Event.ENTER_FRAME, enterFrame);
            stage.removeChild(this);
        }
    }
}