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

RainbowCam

Get Adobe Flash player
by forresto 10 Nov 2010
// forked from forresto's カタカナcam
// forked from ton's マトリックスの世界へようこそ
//なんとなくマトリックスっぽいなにか
package {
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.media.Camera;
    import flash.media.Video;

    [SWF(backgroundColor=0x000000, frameRate=20)]
    public class RainbowCam extends Sprite {
        private const W:int = 465;
        private const H:int = 465;
        
        private var video:Video = new Video(W, H);
        private var videoIn:BitmapData = new BitmapData(W, H, false);
        private var filtered:BitmapData = new BitmapData(W, H, false);
        private var display:Bitmap = new Bitmap(filtered);

        private var colorList:Array = [
            "0x4B0082","0x0000FF","0x008000","0xFF0000","0xFFA500","0xEE82EE","0xFFFF00"];
        private var numColors:int = colorList.length;
        
        public function RainbowCam():void {
            var cam:Camera = Camera.getCamera();
            cam.setMode(W, H, 20, true);
            video.attachCamera(cam);
            addChild(display);
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
        
        private function onEnterFrame(e:Event):void {
            videoIn.draw(video);
            for (var i:int = 0; i < W; i++) {
                for (var j:int = 0; j < H; j++) {
                    filtered.setPixel(i,j, colorList[int((videoIn.getPixel(i, j) / 0xffffff) * numColors)]);
                }
            }
        }
    }
}