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-2-22

Get Adobe Flash player
by mutantleg 22 Feb 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/ou77
 */

package {
    import flash.geom.Matrix;
    import flash.geom.ColorTransform;
    import flash.geom.Rectangle;
    import flash.geom.Point;
    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            
            graphics.beginGradientFill("linear", [0xf0,0xfa0Faf],[100,100],[127,255], new Matrix(0,1,1,0) );
             graphics.drawRect(0,0,465,465);
            graphics.endFill();
            back = new BitmapData(465,465,false,0);
            back.draw(this);
            graphics.clear();
            
            pic = new BitmapData(465,465,true, 0xFF2032F0);
            pic.perlinNoise(23,42,2,5,true,true,7,false);
            pic.colorTransform(pic.rect, new ColorTransform(0.2,0.3,0.5));
            skin = new BitmapData(64, 8, true, 0xFF802010); 
            skin.perlinNoise(23,12,5,2,true,false,7,true);
            
            stage.addEventListener(Event.ENTER_FRAME, onEnter);
        }//ctor
        
        public var pic:BitmapData;
        public var back:BitmapData;
        public var canvas:BitmapData = new BitmapData(465,465,false,0);
        public var skin:BitmapData; 
        
        public var cx:Number = 230;
        public var cy:Number = 230;
        public var cr:Rectangle = new Rectangle(0,0,4,4);
        public var ct:ColorTransform = new ColorTransform(0,0,0,0.33);
        public var mat:Matrix = new Matrix(1,0,0,1,3,4);
        
        public function onEnter(e:Event):void
        {
            graphics.clear();
            graphics.lineStyle(2,0);
            
            graphics.beginBitmapFill(canvas, null,false, true);
             graphics.drawRect(0,0,465,465);
            graphics.endFill();
            
            canvas.unlock();
            canvas.lock();
            
            //canvas.fillRect(canvas.rect, 0);
            canvas.draw(back);
            canvas.draw(pic, mat, ct);
            canvas.draw(pic);

            
            var i:int;
            for (i = 0; i < 64; i++)
            {
                cx += Math.random()*4-2;
                cy += Math.random()*4-2;
                cr.x = cx-2; cr.y = cy-2;
                pic.fillRect(cr, 0);
                
                if (cx < 0) { cx = 465;}   if (cx>465) { cx=0;}
                if (cy < 0) { cy = 465;}   if (cy >465) { cy=0;}
                
            }//nexti
            upRect(pic, cx-16,cy-16,32,32);
            
            
            
        }//onenter
        
        public var tempp:Point = new Point();
        public var tempr:Rectangle = new Rectangle(0,0,1,4); 
        public function upRect(src:BitmapData, ax:int, ay:int, aw:int, ah:int):void
        { 
          var p:Point; p = tempp;
          var r:Rectangle; r = tempr;
          var ex:int; var ey:int;  
          ex =ax+aw; ey = ay+ah;
          
          var i:int; var k:int; 
          for (k = ax; k < ex; k+=1)
          for (i = ay; i < ey; i+=1) 
          {    
            if (src.getPixel(k,i) != 0)
            if (src.getPixel(k,i+4) != 0)
            if (src.getPixel(k,i-1) == 0)
            { 
             //for (w =0; w<8;w++)  {pic.setPixel(k,i+w,0xFF0000);}
             p.x = k; p.y = i;
             r.x = (k % skin.width);
             src.copyPixels(skin, r, p); 
              i+= 4;
            }
         
            if (src.getPixel(k,i) == 0)
            if (src.getPixel(k,i-4) != 0)
            if (src.getPixel(k,i-1) !=0)
            {
              //for (w=0;w <8;w++)  { pic.setPixel(k,i-w,0xFF);} 
               p.x = k; p.y = i - 4;
               r.x = (k % skin.width);
               src.copyPixels(skin, r, p); 
             i+=1;
            } 
          }//nextki
          
        }//uprect
        
        
        
    }//classend
}