forked from: vintage webcam
old webcam
// forked from minon's vintage webcam
// old webcam
package {
import flash.display.*;
import flash.events.Event;
import flash.filters.BlurFilter;
import flash.filters.ColorMatrixFilter;
import flash.filters.GlowFilter;
import flash.media.Camera;
import flash.media.Video;
[SWF(width="465", height="465", frameRate="15")]
public class Main extends Sprite {
private var _cam:Camera;
private var _video:Video;
private var _canvas:BitmapData;
private var _noise:Bitmap;
private var _blur:BlurFilter;
public function Main():void {
init();
}
private function init():void {
_cam = Camera.getCamera();
_cam.setMode( 200, 200, 15 );
_video = new Video( 475 , 475 );
_video.attachCamera( _cam );
_video.x = _video.y = -5;
this.addChild( _video );
var shadow:Sprite = new Sprite();
shadow.graphics.beginFill(0xFFFFFF);
shadow.graphics.drawRect( 0, 0, 465, 465 );
shadow.graphics.endFill();
shadow.filters = [ new GlowFilter( 0x000000, 0.9, 100, 100, 2, 2, true, true) ];
shadow.blendMode = BlendMode.OVERLAY;
this.addChild( shadow );
_noise = new Bitmap( new BitmapData( 465, 465, true, 0xFFFF0000 ) );
_noise.blendMode = BlendMode.HARDLIGHT;
_noise.alpha = 0.3;
this.addChild( _noise );
var matrix:Array = new Array();
matrix = matrix.concat([1.0, -0.2, -0.2, 0.0, 100]); // red
matrix = matrix.concat([-0.2, 0.85, -0.2, 0.0, 50]); // green
matrix = matrix.concat([-0.2, -0.2, 0.5, 0.0, 60]); // blue
matrix = matrix.concat([0, 0, 0, 1.0, 0]); // alpha
_blur = new BlurFilter( 10, 10 );
_video.filters = [ _blur, new ColorMatrixFilter( matrix ) ];
this.addEventListener( Event.ENTER_FRAME, _update );
}
private function _update(e:Event):void {
_noise.bitmapData.noise( Math.random() * 100, 0, 150, 7, true );
_blur.blurX = Math.random() * 10;
_blur.blurY = Math.random() * 10;
}
}
}