forked from: flash on 2015-1-31

by hemingway forked from flash on 2015-1-31 (diff: 12)
♥0 | Line 67 | Modified 2015-02-03 08:28:51 | MIT License
play

ActionScript3 source code

/**
 * Copyright hemingway ( http://wonderfl.net/user/hemingway )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/eehW
 */

// forked from mutantleg's flash on 2015-1-31
package {
    import flash.display.StageQuality;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.geom.Matrix;
    import flash.display.Sprite;
    import net.hires.debug.Stats;
    [SWF(frameRate=60)]
    public class FlashTest extends Sprite {
        public function FlashTest() {
                        
                        
                        
            skin = new BitmapData(256, 256, true, 0);
            skin.perlinNoise(45,23, 8,42, true,true,7,true);
            
            skin.fillRect(new Rectangle(0,0, 1, skin.height), 0);
            skin.fillRect(new Rectangle(skin.width-1,0, 1, skin.height), 0);
            skin.fillRect(new Rectangle(0,0, skin.width, 1), 0);
            skin.fillRect(new Rectangle(0,skin.height-1, skin.width, 1), 0);

           var tmp:BitmapData;

           var i:int;           
           for (i = 0; i < 256; i += 12)
           {
            var c:uint;   var m:int;
            m = i;
            c = (m << 24) | (m<<16) | (m << 8) | 0xFF000000;
             tmp  = new BitmapData(skin.width, skin.height, true, 0);
              tmp.draw(skin);
              tmp.threshold(skin, skin.rect, new Point(0,0), "<=", c, 0, 0xFFffFFff); 
              //tmp.noise(23);
             vecPic.push(tmp);             
             
            tmp.fillRect(new Rectangle(0,0, 1, skin.height), 0);
            tmp.fillRect(new Rectangle(skin.width-1,0, 1, skin.height), 0);
            tmp.fillRect(new Rectangle(0,0, skin.width, 1), 0);
            tmp.fillRect(new Rectangle(0,skin.height-1, skin.width, 1), 0);

           }//nexti
            
            
            addChild(new Stats());
 
            stage.addEventListener(Event.ENTER_FRAME, onEnter);
        }//ctor
        
        public var skin:BitmapData;
        public var mat:Matrix = new Matrix();
        
        public var vecPic:Vector.<BitmapData> = new Vector.<BitmapData>(0, false); 
        
        public var gt:int = 0;
        
        public function onEnter(e:Event):void
        {
            
            gt += 1;
            
            var ang:Number;
            //ang = 45 * (3.1415/180);
            ang = (gt) * (3.1415/180);
            
            mat.identity();
            mat.a = Math.cos(ang);            mat.b = -Math.sin(ang)*0.8; 
            mat.c = Math.sin(ang);            mat.d = Math.cos(ang)*0.2;

         
            mat.tx = Math.sin(ang) *- 128 + Math.cos(ang)*-128;
            mat.ty = Math.cos(ang) * -64  + Math.sin(ang)* 64;
       
               mat.scale(1.75, 1.75);
       
            mat.ty += 465*0.5;            mat.tx += 465*0.5;
       
            graphics.clear();
            
            var i:int; var num:int; var a:BitmapData;
            num = vecPic.length;
            for (i = 0; i < num; i++)
            { 
                mat.ty -=3.3;
                a = vecPic[i];
                graphics.beginBitmapFill(a, mat, false, false);
                graphics.drawRect(0,0,465,465);
                graphics.endFill();
            }  
        
        
        }//onenter 
        
    }//classend
}