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 2015-9-5

Get Adobe Flash player
by mutantleg 05 Sep 2015
    Embed
/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/e67L
 */

package {
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
       

         graphics.clear();
         graphics.lineStyle(2, 0);

         var mw:int; var mh:int;
         mw = 8; mh =8;
         vecVert = getVert(mw,mh, 32,32);
         vecFace = getFace(mw,mh);

          var i:int; var num:int;
          var sx0:Number; var sy0:Number; var sz0:Number; 
          var sx1:Number; var sy1:Number; var sz1:Number; 
          var sx2:Number; var sy2:Number; var sz2:Number;
          
          //drawLine(0,0,0, 200,0,0);     drawLine(0,0,0, 0,0,200);
          
          var ax:Number; var az:Number;
          var m:Number;
           
           ax = 4 * 32;
           az = 4 * 32;
           m = 4 * 32;
           
          num = vecVert.length;
          for (i=0;i<num;i+=3)
          {
            var d:Number;
            d = getMag(ax-vecVert[i], az-vecVert[i+2] );
              
            vecVert[i+1] = m - d;
            
            
          }//nexti
          
         
          
          
          var k:int;
          num = vecFace.length;
          for (i =0; i<num; i+=3)
          {       
             k = vecFace[i] * 3;     sx0 = vecVert[k];  sy0 = vecVert[k+1]; sz0 = vecVert[k+2];
             k = vecFace[i+1] *3;    sx1 = vecVert[k];  sy1 = vecVert[k+1]; sz1 = vecVert[k+2];
             k = vecFace[i+2] *3;    sx2 = vecVert[k];  sy2 = vecVert[k+1]; sz2 = vecVert[k+2];
             
             drawLine(sx0,sy0,sz0, sx1,sy1,sz1);
             drawLine(sx1,sy1,sz1, sx2,sy2,sz2);
             drawLine(sx2,sy2,sz2, sx0,sy0,sz0);
             /*
             graphics.moveTo(sx0,sy0);
             graphics.lineTo(sx1,sy1);
             graphics.lineTo(sx2,sy2);
             graphics.lineTo(sx0,sy0);            
             */ 
          }//nexti
         
                  
        }//ctor
        
        public function getMag(ax:Number, ay:Number):Number
        { return Math.sqrt(ax*ax+ay*ay); }
        
       
        public var rendw:Number = 465 * 0.5;        public var rendh:Number = 465 * 0.5;
        public var camx:Number = 0;        public var camy:Number = 0;        public var camz:Number = 0; 

        public function drawLine(ax:Number, ay:Number, az:Number,
        bx:Number, by:Number, bz:Number):void
        {
           var sx:Number; var sy:Number;     
           ax -= camx; ay -= camy; az -= camz;
           bx -= camx; by -= camy; bz -= camz;
           sx = ax - az + rendw;    sy = (ax * 0.5) + (az * 0.5) - ay;
            graphics.moveTo(sx,sy);
           sx = bx - bz + rendw;    sy = (bx * 0.5) + (bz * 0.5) - by;
            graphics.lineTo(sx, sy);
        }//drawline 
       
       
        public var vecVert:Vector.<Number>;
        public var vecFace:Vector.<int>;
        
        public function getVert(mw:int, mh:int,  cw:Number, ch:Number):Vector.<Number>
        { 
         var i:int; var k:int; var num:int; var w:int;
         var yt:int;  var vec:Vector.<Number>;          
         num = (mw+1)*(mh+1);    vec = new Vector.<Number>(num*3,false);   
         w = 0;
           for (i = 0; i < (mh+1); i+=1)
           {   yt = i*(mw+1);            
            for (k = 0; k < (mw+1); k+=1)
            {  vec[w] =   k*cw;    vec[w+1] = 0;     vec[w+2] = i*ch;                
               w += 3;         
            }//nextk
           }//nexti
           return vec;     
        }//getvert
        
        public function getFace(mw:int, mh:int):Vector.<int>
        {
           var i:int; var k:int; var w:int; var num:int;
           var yt:int;  var vec:Vector.<int>;      
           num = mw * mh;     vec = new Vector.<int>(num ,  false);                
           w = 0;
           for (i=0;i<mh;i+=1)
           {   yt = i * (mw+1);
               for (k=0;k<mw;k+=1)
               {
                  vec[w] = 0 + k + yt; //0
                  vec[w+1] = 0 + k + (mw+1) + yt; //1
                  vec[w+2] = 1 + k + yt; //2                                   
                  vec[w+3] = 1 + k + yt; //2
                  vec[w+4] = 0 + k + (mw+1) + yt; //1
                  vec[w+5] = 1 + k + (mw+1) + yt; //3
                  w+=6;  
               }//nextk           
           }//nexti 
           return vec;
         }//getface
        
        
    }//classend
}