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

MosaicCamera

MosaicCamera.as
Get Adobe Flash player
by kadal 08 Apr 2009
// forked from kadal's BlurCamera
// forked from kadal's BasicCamera
/* MosaicCamera.as */
package {
    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.media.Camera;
    import flash.media.Video;
    import flash.events.Event;
    import flash.filters.BlurFilter;
    import net.hires.debug.Stats;

    
    [SWF(backgroundColor="#000000", frameRate=15)]
    
    public class BlurCamera extends Sprite {
        
        private var SW:Number = stage.stageWidth;
        private var SH:Number = stage.stageHeight;
        
        private var myCamera:Camera;
        private var myVideo:Video;
        private var myDraw:Sprite= new Sprite();
        private var myStage:Sprite = new Sprite();

        private var pSize:Number = 5;
             
        public function BlurCamera():void {
            myCamera = Camera.getCamera();
            myCamera.setMode(500, 500, 15);
            myVideo = new Video(stage.stageWidth, stage.stageHeight);
            myVideo.attachCamera(myCamera);
            
            /*
            var filters_array:Array = new Array();
            var myBlur:BlurFilter = new BlurFilter(10, 0, 5);
            filters_array.push(myBlur);
            myStage.filters = filters_array;
            */          
            
            addChild(myStage);
            myStage.addChild(myDraw);
            addChild(new Stats());
            
            addEventListener(Event.ENTER_FRAME, xDraw);
        }
        
        public function xDraw(evt:Event):void{

            pSize = Math.random() * 10 + 5;

            var myBmd:BitmapData = new BitmapData(SW, SH);
            myBmd.draw(myVideo);
             
            myDraw.graphics.clear();
             
            for (var iX:int=0; iX<SW/pSize; iX++) {
                 for (var iY:int=0; iY<SH/pSize; iY++) {
                     var pick:int = myBmd.getPixel(iX*pSize, iY*pSize);
                     myDraw.graphics.beginFill(pick)
                     myDraw.graphics.drawCircle(iX * pSize, iY * pSize, pSize/2);
                     myDraw.graphics.endFill();
                     
                 }
                 
            }
        }
    }
}