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

forked from: スナスナ

...
@author @kndys
Get Adobe Flash player
by knd 04 Nov 2010
// forked from knd's スナスナ
package 
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BitmapDataChannel;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.filters.ColorMatrixFilter;
    import flash.geom.ColorTransform;
    import flash.geom.Point;
    import flash.media.Camera;
    import flash.media.Video;
    import flash.utils.getTimer;
    
    /**
     * ...
     * @author @kndys
     */
    public class Main extends Sprite 
    {
        private static const _W:Number = 232;
        private static const _H:Number = 232;
        private static const _PT0:Point = new Point();
        
        private var _camera:Camera;
        private var _video:Video;
        private var _noise:BitmapData;
        private var _videoImage:BitmapData;
        private var _canvas:BitmapData;
        private var _filter:ColorMatrixFilter;
        
        public function Main():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
        
        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point
            _camera = Camera.getCamera();
            _camera.setMode(_W, _H, 30);
            _video = new Video(_W, _H);
            _video.attachCamera(_camera);
            
            _noise = new BitmapData(_W, _H, true, 0);
            _videoImage = new BitmapData(_W, _H, true, 0);
            _canvas = new BitmapData(_W, _H, true, 0);
            
            _filter = new ColorMatrixFilter([
                0.29891, 0.58661, 0.11448, 0, 0,
                0.29891, 0.58661, 0.11448, 0, 0,
                0.29891, 0.58661, 0.11448, 0, 0,
                0, 0, 0, 1, 0
            ]);
            
            scaleX = scaleY = 2.0;
            addChild(new Bitmap(_canvas));
            addEventListener(Event.ENTER_FRAME, loop);
        }
        
        private function loop(e:Event):void 
        {
            _noise.noise(getTimer(), 0x0, 0xff, BitmapDataChannel.ALPHA, false);
            _videoImage.draw(_video);
            _videoImage.copyChannel(_noise, _noise.rect, _PT0, BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA);
            _canvas.fillRect(_canvas.rect, 0xffcccccc);
            _canvas.draw(_videoImage);
            _canvas.threshold(_canvas, _canvas.rect, _PT0, "<", 0xaa, 0xff000000, 0xff);
            _canvas.threshold(_canvas, _canvas.rect, _PT0, ">=", 0xaa, 0xffffffff, 0xff);
        }
        
    }
    
}