flash on 2009-12-30
/**
* Copyright h_ike ( http://wonderfl.net/user/h_ike )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zk1v
*/
package {
import flash.media.Video;
import flash.media.Camera;
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class FlashTest extends Sprite {
private var canvas:BitmapData;
private var bitmap:Bitmap;
private var mtrx:Matrix;
private var video:Video;
private var mapSprite:Sprite;
private var mapSpriteBmd:BitmapData;
public function FlashTest() {
var camera:Camera = Camera.getCamera();
if(camera == null){
return;
}
camera.setMode(320,240,30);
video = new Video();
video.attachCamera(camera);
canvas = new BitmapData(320,240);
bitmap = new Bitmap(canvas);
addChild(video);
addChild(bitmap);
bitmap.y = 240;
mtrx = new Matrix();
mtrx.scale(1,-1);
mtrx.translate(0,240);
//
mapSprite = new Sprite();
mapSprite.graphics.beginGradientFill("linear",[0xffffffff,0x000000],[1,1],[0,255]);
mapSprite.graphics.drawRect(0,0,320,240);
mapSpriteBmd = new BitmapData(320,240,true);
mapSpriteBmd.draw(mapSprite);
addEventListener(Event.ENTER_FRAME,loop);
}
private function loop(e:Event):void{
canvas.draw(video,mtrx);
canvas.merge(mapSpriteBmd,mapSpriteBmd.rect,new Point(),0,0,0,1);
}
}
}