流れ落ちるやつ
package {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.filters.BlurFilter;
import flash.filters.ColorMatrixFilter;
import flash.media.Video;
import flash.media.Camera;
import flash.events.Event;
import flash.geom.Matrix;
public class Main extends MovieClip {
//Sprite
public const wrapper:Sprite = new Sprite();
//Video
public const video:Video = new Video(640,480);
//BitmapData
public const before:BitmapData = new BitmapData(640,480,false,0x000000);
public const difBmp:BitmapData = new BitmapData(640,480,false,0x000000);
public const nowBmp:BitmapData = new BitmapData(640,480,false,0x000000);
//Bitmap
public const dif:Bitmap = new Bitmap(difBmp);
public const now:Bitmap = new Bitmap(nowBmp);
//Matrix
public const matrix:Matrix = new Matrix();
//-------------------------
// コンストラクタ
//-------------------------
public function Main() {
//カメラとビデオの設定
var cam:Camera = Camera.getCamera();
cam.setMode(640,480,24);
video.attachCamera(cam);
//
var b:Sprite = new Sprite();
b.graphics.beginFill(0);
b.graphics.drawRect(0,-10,640,10);
addChild(wrapper);
wrapper.addChild(now);
wrapper.addChild(dif);
wrapper.addChild(b);
dif.blendMode = "screen";
now.scaleY = 1.1;
now.y = stage.stageHeight-now.height;
wrapper.filters = [new BlurFilter(16,16,2)];
//色
var m:Array = [];
m = m.concat([1.5, -0.3, -0.3, 0, 1]); // red
m = m.concat([-0.3, 1.5, -0.3, 0, 1]); // green
m = m.concat([-0.3, -0.3, 1.5, 0, 1]); // blue
m = m.concat([0, 0, 0, 1, 0]); // alpha
var colMatrix:ColorMatrixFilter = new ColorMatrixFilter();
colMatrix.matrix = m;
filters = [colMatrix];
//左右反転
matrix.scale(-1, 1);
matrix.translate(cam.width,0);
//
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
//-------------------------
// Enter Frame
//-------------------------
private function onEnterFrame(e:Event):void {
difBmp.draw(video,matrix);
difBmp.draw(before,null,null,"difference");
dif.visible = true;
nowBmp.draw(wrapper);
dif.visible = false;
before.draw(video,matrix);
}
}
}