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-1-21

Get Adobe Flash player
by mutantleg 21 Jan 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/pLmB
 */

package {
    import flash.geom.Vector3D;
    import flash.events.Event;
    import flash.geom.Matrix3D;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        
        public var vecVert:Vector.<wVert>;
        
        public function FlashTest() {
            
            var i:int;
            var k:int;
            var a:wVert;
            
            vecVert = new Vector.<wVert>(0,false);
            
            for (i = -8; i < 8; i++)
            {
                for (k = -8; k < 8; k++)
                {
                    a = new wVert(i*16, 0, k*16);
                    vecVert.push(a);
                }//nextk
            }//nexti
            
            stage.addEventListener(Event.ENTER_FRAME, onEnter);
        }//ctor
        
        public var mat:Matrix3D = new Matrix3D();
        
        public var ang:Number = 0;
        public var wave:Number = 0;
        public function onEnter(e:Event):void
        {
            var vec:Vector.<Number>;
            
            ang += 0.2;
            
            mat.identity();
            //mat.appendRotation(30, Vector3D.X_AXIS);           
            mat.appendRotation(ang, Vector3D.Y_AXIS);
            mat.appendRotation(30, Vector3D.X_AXIS);
            //mat.appendRotation(ang/2, Vector3D.Z_AXIS);
            
            vec = mat.rawData;
            
            var i:int;
            var num:int;
            var a:wVert;
            var sx:Number;
            var sy:Number;
            var sz:Number;
            
            num = vecVert.length;
            
            graphics.clear();
            graphics.lineStyle(1,0);
            
            //graphics.drawRect(20,20,200,200);
            
            var k:Number;
            wave += 0.15;
           // k = ang/360;
            k = wave;
            
            for (i = 0; i < num; i++)
            {
                a = vecVert[i];
                
                a.cy= Math.sin(k)*4;
                k+= 0.7;
                
                //sx = a.cx;
                //sy = a.cy;
                
                sx = vec[0]*a.cx + vec[4] * a.cy + vec[8] *a.cz;
                sy = vec[1]*a.cx + vec[5] * a.cy + vec[9] *a.cz;
                sz = vec[2]*a.cx + vec[5] * a.cy + vec[10] * a.cz;
                
                
                
                graphics.drawCircle(sx+225,sy+225, 2); // * ((32+sz)/64)+2);
                graphics.moveTo(sx+225,sy+225);
                graphics.lineTo(sx+225,sy+225+16);
                
            }//nexti
            
           // graphics.drawRect(40,40,50,50);
            
         }//onenter
        
    }//classend
}

internal class wVert
{
    public var cx:Number = 0;
    public var cy:Number = 0;
    public var cz:Number = 0;
    
    public var px:Number = 0;
    public var py:Number = 0;
    public var pz:Number = 0;
    
    public function wVert(x:Number=0,y:Number=0,z:Number=0)
    {
        cx = x;
        cy = y;
        cz = z;
    }//ctor
    
};//classend