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 2014-9-1

Get Adobe Flash player
by mutantleg 31 Aug 2014
/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/qYBC
 */

package {
      
    import flash.display.Graphics;
    import flash.display.Sprite;
    import flash.events.Event;
    
    public class FlashTest extends Sprite {

         public var top:xLimb;

        public function FlashTest() {
            // write as3 code here..
            
              var b:xLimb;              var a:xLimb;
              a = new xLimb();
              a.cx = 200;
              a.cy = 200;
              a.rad = 16;
              addLimb(a);
              top = a;
              
              var w:Number;              var i:int;              var k:int;
             
              for (k = 0;k < 4; k++)
              {
              b = top;
              w = 0;
              for (i = 0; i < 5; i++)
              {
                a = new xLimb();
                a.ox = 30; a.oy = 0; a.oang = 0;
                a.oang = w; w += 0.2;
                if (i == 0) { a.ox =0; a.pang = k * 1.57 * 0.5; }
                if (i == 4) { a.rad = 8;} else { a.rad = 1;}
                addLimb(a);
                b.addChild(a);
                b = a;
              } //nexti
              }//nextk
          stage.addEventListener(Event.ENTER_FRAME, onEnter);

        }//ctor
        
        
    public function onEnter(e:Event):void
    {
      var g:Graphics;
      g = this.graphics;
      g.clear();
      g.lineStyle(2, 0);

        top.ang += 0.04;
      
      var i:int; var num:int; var a:xLimb;
      num = vecLimb.length;
      for (i = 0; i < num; i++)
      {  a = vecLimb[i];     if (a.parent != null) { continue; }   a.update(); }
      for (i = 0; i < num; i++)   {  a = vecLimb[i];    a.render(g); }
      
      gameTime += 1;
    }//onenter
    
    
    public var vecLimb:Vector.<xLimb> = new Vector.<xLimb>(0, false);
    public function addLimb(a:xLimb):void { a.game = this; a.id = curId; curId += 1; vecLimb.push(a); }
    public var gameTime:int = 0;
    public var curId:int = 1;
    
    }//classend
       
}

import flash.display.Graphics;
import flash.display.Sprite;


class xLimb
{
  public var game:FlashTest = null;
  
  public var id:int = -1;
  
  public var cx:Number = 0;  public var cy:Number = 0;  public var ang:Number = 0;
  public var ox:Number = 0;  public var oy:Number = 0;  public var oang:Number = 0;
  public var px:Number = 0;  public var py:Number = 0;  public var pang:Number = 0;
 
  public var parent:xLimb = null;
  public var vecChild:Vector.<xLimb> = new Vector.<xLimb>(0, false);
  
  public var rad:Number = 8;
  
  
  public function move():void
  {
     var m:Number;
     m = game.gameTime * 0.05;
     oang = pang + Math.sin(m);
     
  }//move
 
  public function update():void
  {
    //trace("",id,cx,cy);
    move();
    if (parent != null) { attachToXY(parent, ox, oy, oang); } 
    updateChild();
  }//update
  
  public function render(g:Graphics):void
  {  
    g.drawCircle(cx, cy, rad);
    g.moveTo(cx, cy); g.lineTo(Math.cos(ang) * 8 + cx, Math.sin(ang) * 8 + cy);
    if (parent != null) { g.moveTo(cx, cy); g.lineTo(parent.cx, parent.cy); } 
  }//render  
   
  public function addChild(a:xLimb):void  { a.parent = this; vecChild.push(a);  }
  
  public function updateChild():void
  {
    var i:int; var num:int; var a:xLimb;
    num = vecChild.length;
    for (i = 0; i < num; i++)  {  a = vecChild[i];   a.update();  }
  }//upchild

  public function attachToXY(a:xLimb, ax:Number, ay:Number, aang:Number):void
  {
    var ca:Number;      var sa:Number;     
     ca = Math.cos(a.ang); sa = Math.sin(a.ang);
     cx = ca*ax - sa*ay + a.cx; 
     cy = sa*ax + ca*ay + a.cy;
     ang = a.ang + aang;
  }//attach

  
}//xlimb