In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

FP10.1 での Camera テスト用

Get Adobe Flash player
by kamexy 24 Feb 2010
/**
 * Copyright kamexy ( http://wonderfl.net/user/kamexy )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4Pqj
 */

package {
	
	import flash.display.Sprite;
	import flash.media.Camera;
	
	[SWF(backgroundColor="#ffffff", frameRate=30, width=350, height=700)]
	public class CameraTest extends Sprite {
		
		public function CameraTest() {
			
			var prev:VideoView;
			for ( var i:uint=0; i < Camera.names.length; i++ ) {
				
				var current:VideoView = new VideoView( i );
				current.y = prev ? prev.y + prev.height : 0;
				addChild( current );
				
				prev = current;
			}
		}
	}
}

import flash.display.Sprite;
import flash.media.Camera;
import flash.media.Video;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;

class VideoView extends Sprite {
	
	private var video:Video;
	private var nameLabel:TextField;
	
	public function VideoView(cameraIndex:uint) {
		
		video = new Video( 160, 120 );
		video.attachCamera( Camera.getCamera( cameraIndex.toString() ) );
		//video.attachCamera( Camera.getCamera( Camera.names[ cameraIndex ] ) );
		
		addChild( video );
		
		nameLabel = new TextField();
		nameLabel.autoSize = TextFieldAutoSize.LEFT;
		
		var format:TextFormat = nameLabel.getTextFormat();
		format.font = "_sans";
		format.size = 12;
		format.color = 0x000000;
		format.bold = true;
		
		nameLabel.defaultTextFormat = format;
		nameLabel.text = Camera.names[ cameraIndex ] as String;
		
		addChild( nameLabel );
		
		nameLabel.x = video.width + 5;
	}
}