in following link http://www.tuttoaster.com/create-a-camera-application-in-flash-using-actionscript-3/ how make picture upload directly server after taking picture webcam
package { import flash.display.sprite; import flash.media.camera; import flash.media.video; import flash.display.bitmapdata; import flash.display.bitmap; import flash.events.mouseevent; import flash.net.filereference; import flash.utils.bytearray; import com.adobe.images.jpgencoder; public class caml extends sprite { private var camera:camera = camera.getcamera(); private var video:video = new video(); private var bmd:bitmapdata = new bitmapdata(320,240); private var bmp:bitmap; private var filereference:filereference = new filereference(); private var bytearray:bytearray; private var jpg:jpgencoder = new jpgencoder(); public function caml() { savebutton.visible = false; discardbutton.visible = false; savebutton.addeventlistener(mouseevent.mouse_up, saveimage); discardbutton.addeventlistener(mouseevent.mouse_up, discard); capture.addeventlistener(mouseevent.mouse_up, captureimage); if (camera != null) { video.smoothing = true; video.attachcamera(camera); video.x = 140; video.y = 40; addchild(video); } else { trace("no camera detected"); } } private function captureimage(e:mouseevent):void { bmd.draw(video); bmp = new bitmap(bmd); bmp.x = 140; bmp.y = 40; addchild(bmp); capture.visible = false; savebutton.visible = true; discardbutton.visible = true; } private function saveimage(e:mouseevent):void { bytearray = jpg.encode(bmd); filereference.save(bytearray, "image.jpg"); removechild(bmp); savebutton.visible = false; discardbutton.visible = false; capture.visible = true; } private function discard(e:mouseevent):void { removechild(bmp); savebutton.visible = false; discardbutton.visible = false; capture.visible = true; } } }
the filereference.upload() , filereference.download() functions nonblocking. these functions return after called, before file transmission complete. in addition, if filereference object goes out of scope, upload or download has not yet been completed on object cancelled upon leaving scope. so, sure filereference object remain in scope long upload or download expected continue. http://help.adobe.com/en_us/as2lcr/flash_10.0/help.html?content=00001063.html
Comments
Post a Comment