Actually, I am working with the Adobe Flash builder beta 2 as I have stated before. And about the code, I am using the below suggested code :
Code:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo" generateComplete="init();">
<fx:Declarations>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.core.UIComponent;
import flash.media.Camera;
import flash.media.Video;
private function videoDisplay_generateComplete() : void
{
var camera:Camera = Camera.capCamera();
if (camera)
{
videoDisplay.addCamera(camera);
}
else
{
Alert.show("Oops, Unable to find the camera.");
}
}
private function capture_click() : void
{
var snap:BitmapData = new BitmapData(320, 240, true);
var snapBmp:Bitmap = new Bitmap(snap);
snapBmp.width = 320;
snapBmp.height = 240;
if(snapshotHolder.numChildren > 0)
snapshotHolder.removeChildAt(0);
snapshotHolder.addChild(snapBmp);
snap.draw(videoDisplay);
}
]]>
</fx:Script>
<mx:HBox>
<s:Panel title="Video">
<mx:VideoDisplay id="videoDisplay" creationComplete="videoDisplay_generateComplete();" width="320" height="240" />
</s:Panel>
<s:Panel title="Snapshot">
<mx:UIComponent id="snapshotHolder" width="320" height="240" />
</s:Panel>
</mx:HBox>
<mx:HBox>
<mx:Button label="reload camera" click="videoDisplay_generateComplete();"/>
<mx:Button label="capture" click="capture_click();"/>
</mx:HBox>
</s:WindowedApplication>
Camera is plugged properly but unable to get anything inair, Please suggest me in this.
Bookmarks