第一百二十二章
var camtimer:Timer = new Timer();
camtimer.addEventListener(TimerEvent.TIMER, onCamCheck);
camtimer.addEventListner(TimerEvent.TIMERCOMPLETE, onCamCheckComplete)
function onCamCheck(e:TimerEvent)
{
if(camcheckcount > 0)
{
//If cam can work properly.
if(cam.currentFPS > 0)
{
camfpsfailedcount++;
}
else
{
if(prevCamActivity==curCamActivity)
{
camactivityfailedcount++;
}
prevCamActivity = curCamActivity;
}
camcheckcount--;
}
else
{
timer.Stop();
}
}
function onCamCheckComplete(e:TimerEvent)
{
if(camfpsfailedcount > 0)
{
camStatus = "Failed to acquire control of Camera. Check if another program is using it or current cam driver is proper or if the cam is correctly connected to computer. ";
return;
}
if(camactivityfailedcount > 0)
{
camStatus = "Failed to acquire image of Camera. Check if something is blocking it.";
return;
}
errorLabel.text = camStatus;
publishBtn.enabled = true;
}
DataProvider camdp = new DataProvider(Camera.names);
camList.dataProvider = camdp;
camList.addEventListener(Event.CHANGE,camFun);
function camFun (e:Event) : void {
try
{
camStatus = " ";
camtimer.Stop();
camfpsfailedcount = 0;
curCamActivity = 0;
prevCamActivity = curCamActivity;
camactivityfailedcount = 0;