複数のカメラ

by tmdf
♥0 | Line 20 | Modified 2009-07-07 21:16:35 | MIT License
play

ActionScript3 source code

/**
 * Copyright tmdf ( http://wonderfl.net/user/tmdf )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/bW6H
 */

package {
	import flash.display.Sprite;
	import flash.media.Camera;
	import flash.media.Video;
	
	public class Main extends Sprite {
		
		public function Main():void {
			
			//初期化
			var camera = new Array();
			var video = new Array();
			
			//接続されているカメラの数を取得
			var l:int = Camera.names.length - 1;
			
			//カメラが1台以上接続されている場合
			while (l >= 0) {
				
				//カメラを取得
				camera[l] = Camera.getCamera(String(l));
				
				//CameraとVideoを連携
				video[l] = new Video(camera[l].width, camera[l].height);
				video[l].attachCamera(camera[l]);
				
				//ステージに追加、位置調整
				this.addChild(video[l]);
				video[l].x = video[l].width * l;
				
				l --;
			}
		}
	}
}

Forked