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 2013-5-27

Get Adobe Flash player
by mutantleg 27 May 2013
    Embed
/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/zHDF
 */

package {
    import flash.text.TextField;
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
           
           var a:xNode;
           
           vecNode = new Vector.<xNode>(0, false);
            
            vecNode.push(new xNode(null, 200,200,0));
            a = vecNode[0];
            a.vang = 0.01;
            //vecNode.push(new xNode(vecNode[0], 0,50,0));
           // vecNode.push(new xNode(vecNode[1], 0,30,0));
           // vecNode.push(new xNode(vecNode[1], 30,0,0));
          //  vecNode.push(new xNode(vecNode[2], 50,0,0));
          //  vecNode.push(new xNode(vecNode[4], 0, 40,0));
            
            var i:int;
            
            for (i = 0; i< 64; i++)
            {
                a = new xNode(vecNode[int(Math.random()*(i-1))],
                (Math.random()-0.5)*150, (Math.random()-0.5)*150, Math.random()*6.28);
                a.vang = (Math.random() - 0.5)*0.2;
                vecNode.push(a);
                
            }//nexti
            
            
            vecNode.sort(comp);
            
            deb = new TextField();
            deb.mouseEnabled = false;
            deb.width =320;
            deb.height = 240;
            addChild(deb);
            
            stage.addEventListener(Event.ENTER_FRAME, onEnter);
        }//ctor
        
        public var vecNode:Vector.<xNode>;
        
        public function comp(a:xNode, b:xNode):Number
        {
            if (a.dep == b.dep) { return 0;}
            if (a.dep < b.dep) { return -1;}
            return 1;
        }//comp
        
        public var deb:TextField;
        
        public function onEnter(e:Event):void
        {
            graphics.clear();
            graphics.lineStyle(2, 0);
            
            var i:int;
            var num:int;
            var a:xNode;
            var kx:Number;
            var ky:Number;
            var ka:Number;
            
            num = vecNode.length;
            
            //deb.text ="";
            
            //vecNode[0].ang += 0.02;
           // vecNode[1].ang += 0.04;
           // vecNode[4].ang -= 0.04;
            
            for (i = 0; i < num; i++)
            {
                a = vecNode[i];
                
             //   deb.appendText(""+a.dep);
                
                a.ang += a.vang;
                
                  a.tx = a.cx;
                  a.ty = a.cy;
                  a.tang = a.ang;
                  a.tang = Math.cos(a.ang) * Math.sin(a.ang);  
                  
                if (a.parent != null)
                {
                    kx = a.cx;
                    ky = a.cy;
                    ka = a.parent.tang;
                   a.tx = Math.cos(ka)*kx - Math.sin(ka)*ky;
                   a.ty = Math.sin(ka)*kx + Math.cos(ka)*ky;  
                    
                  a.tx += a.parent.tx;
                  a.ty += a.parent.ty;
                  a.tang += a.parent.tang;   
                  
                  graphics.moveTo(a.tx, a.ty);
                  graphics.lineTo(a.parent.tx, a.parent.ty);
                }
                
                //graphics.drawCircle(a.cx, a.cy, 8);
               // graphics.drawCircle(a.tx, a.ty, 8);
            }//nexti
            
        }//onenter
        
    }//classend
}

internal class xNode
{
    public var cx:Number = 0;
    public var cy:Number = 0;
    public var ang:Number = 0;
    public var vang:Number = 0;
    
    public var tx:Number = 0;
    public var ty:Number = 0;
    public var tang:Number = 0;
    
    public var dep:int = 0;
    public var parent:xNode = null;
    
    public function xNode(p:xNode, x_:Number, y_:Number, a_:Number)
    {
        cx = x_;
        cy = y_;
        ang = a_;
        
        parent = p;
        if (parent != null)
        { dep = parent.dep + 1;}
    }//ctor
    
}//classend