カメラのテスト
package {
import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.media.*;
public class CameraTest extends Sprite{
public function CameraTest():void{
var area:Sprite = this;
var button:Sprite = new Sprite();
button.graphics.beginFill(0xa0a0a0);
button.graphics.drawRect(0, 0, 100, 20);
button.graphics.endFill();
var t:TextField = new TextField();
t.text = 'カメラ起動';
t.selectable = false;
t.x = 20;
t.y = 5;
button.addChild(t);
button.x = 10;
button.y = 10;
area.addChild(button);
button.addEventListener(MouseEvent.MOUSE_DOWN, function(e:MouseEvent):void{
var cam:Camera = Camera.getCamera();
if(!cam) return;
var s:TextField = new TextField();
s.x = 50;
s.y = 300;
area.addEventListener(Event.ENTER_FRAME, function(e:Event):void{
s.text = cam.activityLevel.toString();
});
area.addChild(s);
var count:Number = 0;
cam.addEventListener(ActivityEvent.ACTIVITY, function(e:ActivityEvent):void{
if(e.activating) t.text += '!';
});
var v:Video = new Video(320, 240);
v.attachCamera(cam);
area.addChild(v);
v.x = 50;
v.y = 50;
});
}
}
}