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

WhiteNoise

Get Adobe Flash player
by Cheshir 17 Feb 2015
/**
 * Copyright Cheshir ( http://wonderfl.net/user/Cheshir )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/n9Ot
 */

package {
    import flash.text.TextField;
    import flash.display.BlendMode;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        
        public var modes:Array = [BlendMode.DARKEN, BlendMode.DIFFERENCE,
         BlendMode.LIGHTEN,
        BlendMode.MULTIPLY, BlendMode.SCREEN, BlendMode.SUBTRACT ];
 
        private var foundation:Bitmap;
        private var moved:Bitmap;
        private var log:TextField = new TextField();
  
        public function FlashTest() {
            log.autoSize = 'left';
            log.textColor = 0xff0000;
            log.y = 200; log.x = 20;
            
            foundation = new Bitmap( new BitmapData(stage.stageWidth*2, stage.stageHeight*2, false, 0 ),"auto",true);
            foundation.bitmapData = drawWhiteNoise(foundation.bitmapData);
            moved = new Bitmap( new BitmapData(stage.stageWidth*2, stage.stageHeight*2, false, 0 ),"auto",true);
            moved.bitmapData = drawWhiteNoise(moved.bitmapData);
            moved.y = -stage.stageHeight/2;
            moved.x = -stage.stageWidth/2;
            foundation.x = -stage.stageWidth/2;
            foundation.y = -stage.stageHeight/2;
            moved.blendMode = BlendMode.DIFFERENCE;
            addChild(foundation);
            addChild(moved);
            
            stage.addEventListener(MouseEvent.CLICK, changeMode);
            stage.addEventListener(Event.ENTER_FRAME, move);
            addChild(log);
        }
        private var direct:Number = Math.PI;
        private function move(e:Event):void {
            moved.x += Math.cos(direct)*Math.random();
            moved.y += Math.sin(direct)*Math.random();
            foundation.x -=Math.cos(direct)*Math.random();
            foundation.y -=Math.sin(direct)*Math.random();
            direct += 0.02;
        }
        
        private var modeCounter:int = 0;
        private function changeMode(e:MouseEvent):void{
            moved.blendMode = modes[modeCounter];
            log.text = modes[modeCounter];
            modeCounter++;
            if(modeCounter>modes.length-1) modeCounter = 0;
        }
        
        private function drawWhiteNoise(bit:BitmapData):BitmapData{
            var color:uint = 0;
            for(var i:int = 0; i<bit.width*bit.height/2; i++){
                color = 0xdddddd;
                bit.setPixel(Math.random()*bit.width, Math.random()*bit.height, color);
            }
            return bit;
        }

    }
}