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 2017-2-3

Get Adobe Flash player
by mutantleg 03 Feb 2017
    Embed
/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/onIW
 */

package {
    import flash.geom.Matrix;
    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            
            canvas = new BitmapData(128, 128, false, 0);
            canMat = new Matrix(3,0,0,3,0,0);

            mw=128;mh=128;
            var nw:int; nw = mw*mh;
            vecOne = new Vector.<int>(0,false);
            vecTemp = new Vector.<int>(0,false);

            var i:int; var a:xBlob;
            vecBlob =new Vector.<xBlob>(0,false);
            for(i=0;i<512;i+=1){a =new xBlob(); vecBlob.push(a); }

            stage.addEventListener(Event.ENTER_FRAME, onEnter);            
        }//ctor
        
        public var canvas:BitmapData;
        public var canMat:Matrix;
        public var mw:int = 128;
        public var mh:int = 128;
        public var vecOne:Vector.<int>;
        public var vecTemp:Vector.<int>;
        
        public function setTile(ax:int, ay:int, t:int):void
        { if(ax<0||ax>=mw||ay<0||ay>=mh){return;} 
          var c:int; c = vecOne[ax+(ay*mw)]; if(c>t){return;}
          vecOne[ax+(ay*mw)]=t;
         }

        public var vecBlob:Vector.<xBlob>;
        
        public function onEnter(e:Event):void
        {
          graphics.clear();
          graphics.lineStyle(2, 0);  

          var nw:int; nw=mw*mh;
          var i:int; var k:int; var yt:int;
          
           var swp:Vector.<int>;
           swp = vecOne; vecOne=vecTemp; vecTemp=swp;
          for(i=0;i<nw;i+=1) { vecTemp[i]=0; }
          
          var mx:Number; var my:Number;
          mx=stage.mouseX; my=stage.mouseY;
          
          setTile(mx/3,my/3,64);
          
          var num:int; var a:xBlob;
          num=vecBlob.length;
          for(i=0;i<num;i+=1)
          { a = vecBlob[i];
            a.update();
            setTile(a.cx,a.cy, a.size);
          }//nexti
          
          var w:int;
          for(i=1;i<mh-1;i+=1)
          { yt=i*mw;
              for(k=1;k<mw-1;k+=1)
              {
                  t = vecOne[yt+k];
               
                  w = vecOne[yt+k-1];   if (w>t){t=w-1;}    
                  w = vecOne[yt+k+1];   if (w>t){t=w-1;}    
                  w = vecOne[yt+k-mw];   if (w>t){t=w-1;}    
                  w = vecOne[yt+k+mw];   if (w>t){t=w-1;}    

                  w = vecOne[yt+k-1-mw];   if (w>t){t=w-2;}    
                  w = vecOne[yt+k+1-mw];   if (w>t){t=w-2;}    
                  w = vecOne[yt+k-1+mw];   if (w>t){t=w-2;}    
                  w = vecOne[yt+k+1+mw];   if (w>t){t=w-2;}    
                  
                  t-=1;
                  if (t<0){t=0;}
                  vecTemp[yt+k] = t;
                  
              }//nextk
          }//nexti
          
          var c:int; var t:int;
          for(i=0;i<mh;i+=1)
          { yt=i*mw;
              for(k=0;k<mw;k+=1)
              {
                t = vecTemp[yt+k];
                c=t>0?255:0; 
                //if (t>0&&t<3){c=t*64;} 
                if (t>0&&t<3){c=128;} 
                c=(c<<16)|(c<<8)|c;
                //c = Math.random()*32;
                canvas.setPixel(k,i, c);                 
                  
              }//nextk
          }//nexti

          num=vecBlob.length;
          for(i=0;i<num;i+=1)
          { a = vecBlob[i]; canvas.setPixel(a.cx,a.cy,0x808080); }
          
          
          graphics.beginBitmapFill(canvas, canMat, false, false);
          graphics.drawRect(0,0,384,384);
          graphics.endFill();
          
            
        }//onenter
        
    }//classend
}

internal class xBlob
{
  public var cx:Number=0;
  public var cy:Number=0;
  public var vx:Number=0;
  public var vy:Number=0;
  public var start:int=1;
  public var size:int=8;
  
  public function update():void
  {
    if(start==1){start=0;
    size = Math.random()*8+4;
    cx=Math.random()*128;cy=Math.random()*128;
        vx=Math.random()-0.5; vy=Math.random()-0.5;}
    if(cx<0&&vx<0){vx=-vx;}  
    if(cx>128&&vx>0){vx=-vx;}  
    if(cy<0&&vy<0){vy=-vy;}  
    if(cy>128&&vy>0){vy=-vy;}  
    cx+=vx;cy+=vy;
  }//update    
}//xblob