send Web Cam Image to server
hi all, i am capturing webcam snap and want to send it to php, but my code is not working. Giving runtime error TypeError: Error #1009: Cannot access a property or method of a null object reference. at WebcamApp/uploadSnapshot()[C:Documents and SettingsabcAdobe Flash Builder Beta 2WebcamAppsrcWebcamApp.mxml:99]
Giving error to this line var jpgBytes:ByteArray = jpgEncoder.encode(bitmap.bitmapData);
this is my code private function takeSnapshot():void { imageViewer.visible = true; imageViewer.width = preview.width; imageViewer.height = preview.height; var uiComponent : UIComponent = new UIComponent(); uiComponent.width = webCam.width; uiComponent.height = webCam.height; var photoData:Bitmap = webCam.getSnapshot(); var photoBitmap:BitmapData = photoData.bitmapData; uiComponent.addChild(photoData); imageViewer.addElement(uiComponent); state.text = “”; enableSubmit(); } private function uploadSnapshot():void { if (imageViewer) { var uic:UIComponent = imageViewer.getChildAt(0) as UIComponent; var bitmap:Bitmap = uic.getChildAt(0) as Bitmap; var jpgEncoder:JPEGEncoder = new JPEGEncoder(75); var jpgBytes:ByteArray = jpgEncoder.encode(bitmap.bitmapData); state.text = “starting upload …”; uploadPhoto(jpgBytes); state.text = “upload done”; } }
<s:Panel width="340" height="240" title="Snapshot" id="imageViewer" /