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

sludge

click to show wireframe
Get Adobe Flash player
by mutantleg 27 Nov 2014
/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/w6IV
 */

package {
    import flash.geom.Rectangle;
    import flash.display.StageQuality;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            
            
            stage.quality = StageQuality.LOW;
            
            var num:int;            var i:int;
            var k:int;            var yt:int;
            var w:int;
                        
            mw = 9;            mh = 9;
            
            num = mw*mh;
            vecFace = new Vector.<int>(num,false);
            
           w = 0;
           for (i = 0; i < mh; i++)
           {
                yt = i*(mw+1);            
            for (k = 0; k < mw; k++)
            {
                  vecFace[w] = 0 + k + yt; //0
                  vecFace[w+1] = 0 + k + (mw+1) + yt; //1
                  vecFace[w+2] = 1 + k + yt; //2
                                    
                  vecFace[w+3] = 1 + k + yt; //2
                  vecFace[w+4] = 0 + k + (mw+1) + yt; //1
                  vecFace[w+5] = 1 + k + (mw+1) + yt; //3

                  w+=6;      
                }//nextk
            }//nexti
            

            num = (mw+1)*(mh+1);
            vecVert2 = new Vector.<Number>(num*2,false);
            vecUv = new Vector.<Number>(num*2,false);
            
           var temp:BitmapData;
           temp = new BitmapData(256,256,false,0);
           temp.perlinNoise(32,44,22,44,true,true);
           img = temp;

           canvas = new BitmapData(temp.width,temp.height,false,0);

          stage.addEventListener(MouseEvent.CLICK, onClick);
          stage.addEventListener(Event.ENTER_FRAME, onEnter);            
        }//ctor
        
        public function onClick(e:MouseEvent):void
        { bWire = !bWire; }
        
        public var bWire:Boolean = false;
        
       // public var vecVert:Vector.<xVert>;
        public var vecFace:Vector.<int>;
        public var vecVert2:Vector.<Number>;
        public var vecUv:Vector.<Number>;
        public var mw:int =0;
        public var mh:int = 0;
        
        public var gt:int = 0;
        
        public var img:BitmapData;
        
        public var canvas:BitmapData;

        public function onEnter(e:Event):void
        {
            gt +=1;
            
            var num:int;            var i:int;
            var k:int;            var yt:int;
            var w:int;
            var cw:Number;            var ch:Number;
            cw =32; ch = 32;
            var tx:Number;            var ty:Number;
            tx = 32;
            ty = 32;
            
            var u:Number;           var v:Number;
            u = gt*0.1;
            v = gt*0.1+0.043;
            
           // var sw:Number;
            //var sh:Number;
            tx =0; ty=0;
            cw = 465/mw;
            ch = 465/mh;
            
           w = 0;
           for (i = 0; i < (mh+1); i++)
           {
                yt = i*(mw+1);            
            for (k = 0; k < (mw+1); k++)
            {
                vecVert2[w] = k*cw + tx;
                vecVert2[w+1] = i*ch + ty;
                
                if (k >0 && k <mw)
                { vecVert2[w] += Math.sin(u)*5; u+=0.2; }
                
                if (i > 0 && i < mh)
                { vecVert2[w+1] += Math.cos(v)*7; v+=0.7; }
                
                
                vecUv[w] = k/mw + (Math.sin(gt*0.03)*Math.cos(gt*0.03))*0.07;
                vecUv[w+1] = i/mh + (Math.sin(gt*0.03+1.57)*Math.cos(gt*0.03))*0.07;
                
                w+=2;

            }//nextk
           }//nexti
           
           
           graphics.clear();
           if (bWire){ graphics.lineStyle(1,0); }
  
            
             // tempRect.x = 48+Math.sin(gt*0.1)*32; 
             // tempRect.y = 16;
              //tempRect.width = 32;
             // tempRect.height = 32;
  
          canvas.draw(img);
           //canvas.fillRect(tempRect,0xFF);
           
           
           graphics.beginBitmapFill(canvas,null,true,false);
             graphics.drawTriangles(vecVert2, vecFace, vecUv);
           graphics.endFill(); 

            
                        
        }//onenter
        
        public var tempRect:Rectangle = new Rectangle();
        
        

      
        
    }//classend
}