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-17

Get Adobe Flash player
by mutantleg 17 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/CZr2
 */

package {

    import flash.geom.Rectangle;
    import flash.geom.Point;
    import flash.events.Event;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {

         mapImg = new BitmapData(465,465, false, 0);
         canvas = new BitmapData(465, 465, false, 0);
            
          var i:int;
          for(i=0;i<256;i+=1)
          {
            mapImg.fillRect(new Rectangle(Math.random()*465,Math.random()*265+128,Math.random()*32,Math.random()*32),0xFFffFF);                            
          }//nexti  
          for(i=0;i<256;i+=1)
          {
            mapImg.fillRect(new Rectangle(Math.random()*465,Math.random()*265+256,Math.random()*64,Math.random()*64),0xFFffFF*Math.random());                            
          }//nexti  
          
          vecBlob = new Vector.<xBlob>(0,false);
          
          var a:xBlob;
          for(i=0;i<32;i+=1)
          {
           a = new xBlob(); vecBlob.push(a);
           a.cx = 230; a.cy=120;
           a.cx=Math.random()*300+50;
           a.cy=Math.random()*30+60;           
          }//nexti
            
          stage.addEventListener(Event.ENTER_FRAME, onEnter);
        }//ctor
        
       

        public var vecBlob:Vector.<xBlob>;
        public var pnt:Point = new Point();
   
        public var gt:int = 0;
      
        public function onEnter(e:Event):void
        {

           graphics.clear();
           canvas.fillRect(canvas.rect, 0);
           canvas.copyPixels(mapImg, mapImg.rect, pnt);
           
           var i:int; var num:int; var a:xBlob;
           num = vecBlob.length;
           for(i=0;i<num;i+=1)
           {
             a = vecBlob[i];
             a.update();
           }//nexti
           
           gt+=1;
           
            var wa:Number; 
            var ang:Number;  var ta:Number;
               ang = gt*0.1;
               wa = (gt*3)*0.03;
           for (i=0;i<465;i+=1)
           {
             ang+=0.011;
             wa+=0.03;
             ta = Math.sin(ang*2);  
             ta += Math.sin(wa*2);
             fillRect(canvas,i,400+ta*8,1,128,  0x1314AF);
             fillRect(canvas,i,400+ta*8,1,3,  0x4344AF);
             ta = Math.sin(ang*2+1.5);  
             ta += Math.sin(wa*2+1.5);
             fillRect(canvas,i,410+ta*8,1,128,  0x3344FF);
             fillRect(canvas,i,410+ta*8,1,3,  0x7374FF);
             
           }//nexti          
           
           graphics.lineStyle(2, 0);           
           graphics.beginBitmapFill(canvas,null,false,false); 
            graphics.drawRect(0,0,465,465);
           graphics.endFill();

           for(i=0;i<num;i+=1)
           {
             a = vecBlob[i];
             graphics.beginFill(0xFF,1);
             graphics.drawCircle(a.cx, a.cy, 4);
             graphics.endFill();
           }//nexti
        }//onenter

        
        
    }//classend    
}

    import flash.display.BitmapData;
    import flash.geom.Rectangle;
    import flash.geom.Point;

var mapImg:BitmapData;
var canvas:BitmapData;

function isWall(ax:Number,ay:Number):Boolean
{
  if(ax<0||ax>=465||ay<0||ay>=465){return true;}   
  return mapImg.getPixel(ax,ay)!=0; 
}//iswall

var tempRect:Rectangle = new Rectangle();

function fillRect(img:BitmapData, ax:int, ay:int, aw:int, ah:int, c:int):void
{
    tempRect.width = aw ;    tempRect.height = ah;
    tempRect.x = ax;    tempRect.y = ay;
    img.fillRect(tempRect, c);    
}//fill 


function makeHole(ax:Number,ay:Number,r:Number):void
{
    tempRect.width = r*2;    tempRect.height =r*2;
    tempRect.x = ax-r;    tempRect.y = ay-r;
    mapImg.fillRect(tempRect, 0);
}//makehole

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 dir:int = 0;
   
   public function isStuck(ax:Number,ay:Number):Boolean
   {
     if (isWall(ax-8,ay)==false) { return false;}    
     if (isWall(ax+8,ay)==false) { return false;}    
     if (isWall(ax,ay-8)==false) { return false;}    
     if (isWall(ax,ay+8)==false) { return false;}    
     
     return true;
   }//isstuck

 public function update():void
 {
     if (Math.random()<0.2&&vy==0) { vy= -2.5; vx = Math.random()*8-4; }
     
     vy+=0.2; if (vy>3){vy=3;}
     
     if (isWall(cx-8,cy)&&vx<0) { if (vx<-2){makeHole(cx+8,cy,8);} vx*=-0.5; }    
     if (isWall(cx+8,cy)&&vx>0) {  if (vx>2){makeHole(cx+8,cy,8);}  vx*=-0.5; }    
     if (isWall(cx,cy-8)&&vy<0) { vy=0;}    
     if (isWall(cx,cy+8)&&vy>0) { if (vy>2){makeHole(cx,cy,8);}  vy=0;}    
     else if (isWall(cx+4,cy+8)&&vy>0) { if (vy>2){makeHole(cx,cy,8);}  vy=0;}    
     else if (isWall(cx-4,cy+8)&&vy>0) { if (vy>2){makeHole(cx,cy,8);}  vy=0;}    
     
     
     if (isStuck(cx+vx,cy+vy)){vx=0; vy=0;}
     else
     {
      if (isStuck(cx+vx, cy)) {vx=0;}
      if (isStuck(cx,cy+vy)) { vy=0; }
     }
    cx+=vx; cy+=vy;     
     
 }//update    
    
}//xblob