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

Just fooling around with my webcam

Nothing interesting
Get Adobe Flash player
by antalg 14 Nov 2011
    Embed
package {
    import flash.filters.BlurFilter;
    import flash.geom.Point;
    import flash.display.AVM1Movie;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.text.TextFieldType;
    import flash.text.TextField;
    import flash.filters.ColorMatrixFilter;
    import flash.events.Event;
    import flash.media.Camera;
    import flash.media.Video;
    import flash.display.Sprite;
    
    [SWF(Width=465, Height=465)]
    
    public class FlashTest extends Sprite {
        private const W:int = 465;
        private const H:int = 465;
        
        public function FlashTest() {
            video = new Video(W, H);
            camara = Camera.getCamera();
            camara.setMode(W, H, 30);
            video.attachCamera(camara);
            
            addChild(new Bitmap(canvas));
            addChild(txt);
            txt.text = "0.5";
            txt.textColor = 0x0000FF;
            txt.type = TextFieldType.INPUT;
            
            stage.addEventListener(Event.ENTER_FRAME, doStuff);
        }
        
        private var txt:TextField = new TextField();
        private var canvas:BitmapData = new BitmapData(W, H);
        
        private var video:Video;
        private var camara:Camera;
        
        private var cmf:ColorMatrixFilter = new ColorMatrixFilter();         
        private var bf:BlurFilter = new BlurFilter(4,4,2);
        
        private function doStuff(e:Event):void {
            var bmd:BitmapData = new BitmapData(W,H);
            bmd.draw(video);
            canvas.fillRect(canvas.rect, 0xFF000000);
            
            //var x:int = 255*Number(txt.text);
            //var color:uint = (x<<16)|(x<<8)|x;
            
            bmd.applyFilter(bmd, canvas.rect, new Point(0,0), bf);
            
            
            canvas.threshold(bmd, canvas.rect, new Point(0,0), ">=", 0xFF<<24|0xFFFFFF*Number(txt.text), 0xFFFF0000, 0xFFFFFFFF);
        }
    }
}