A camera is required for normal playback.
Ideas:
Using the camera and online screen capture in the previous Flash/flex learning note (2): capture the camera has already been mentioned, so do not paste it again. As for saving files on the client, flash is also very simple to use: directly call filereference can be, in order to reduce the image size, may also use as3.0 extension Library (Project address http://code.google.com/p/as3corelib ), convert the location of the BMP format to JPEG and save it.
Extension:
Combined with the methods described in this article and the flash/flex learning notes (4): how to open a webpage and get/post data, you can easily make "online dashboard" or "online generation of membership headers" and other functions.
Source code:
VaR W: Int = stage. stagewidth; // original scene width var H: Int = stage. stageheight; // The original height of the scene stage. scalemode = stagescalemode. no_scale; // The stage cannot be scaled, but does it seem ineffective? VaR video: Video; var camera: Camera = camera. getcamera (); // get the camera lblauthor. addeventlistener (mouseevent. click, function () {navigatetoURL (New URLRequest ("http://www.cnblogs.com/yjmyzz"), "_ blank")}); // detect the camera if (CAMERA = NULL) {trace ("no camera detected! "); Lbl1.text =" no camera detected! "; Btncapture. visible = false; tilelst1.visible = false; lblmemo. visible = false;} else {Camera. addeventlistener (activityevent. activity, activityhander); video = new video (camera. width, camera. height); trace ("video width:" + camera. width + ", video Height:" + camera. height); video. attachcamera (CAMERA); // locate the horizontal center point video. X = (W-video. width)/2; video. y = 10; addchild (video); // load it to the current stage. X = (W-btncapture. width)/2; btncapture. y = video. Y + video. height + 5; btncapture. addeventlistener (mouseevent. click, captureimage);} // detects camera activity changes. Function activityhander (E: activityevent): void {trace ("activityhander:" + E);} var DP: dataprovider = new dataprovider (); tilelst1.addeventlistener (mouseevent. click, saveimage); // double-click to save to the local function saveimage (E: mouseevent) {If (e.tar get. hasownproperty ("Source") {// check that the VaR worker Encoder: jpgencoder = new jpgencoder () is saved only when the image is clicked. var bitmap: bitmap = e.tar get. data. source; var incluarr: bytearray = incluencoder. encode (bitmap. bitmapdata); // compressed into JPEG trace (jpegarr. length); var file: filereference = new filereference (); var filename: String = e.tar get. data. label + ". jpg "; // set the file name. save (jpegarr, filename); // save to local} // video processing function captureimage (E: mouseevent): void {// trace ("You clicked the button "); vaR bit: bitmapdata = new bitmapdata (video. width, video. height); bit. draw (video); var BMP: bitmap = new Bitmap (BIT); var D: Date = new date (); DP. additem ({label: "" + D. getfullyear () + d. getmonth () + d. getday () + d. gethours () + d. getminutes () + d. getseconds () + d. getmilliseconds (), source: BMP}); tilelst1.dataprovider = DP; trace (DP. length); tilelst1.scrolltoindex (DP. length-1); // the scroll bar is automatically pulled to the last image} STOP ();
sample source Code download: http://cid-2959920b8267aaca.skydrive.live.com/self.aspx/Flash/GetCamera2.rar