开发者

Compiler error using Camera.isSupported

I'm coding an AS3 web app which needs to access the webcam. The webcam code works fine apart from my initial attempt to detect whether a webcam is plugged into the pc.

I'm trying to use Camera.isSupported as specified in the Adobe docs but I get a compiler error telling me

1119: Access of possibly undefined property isSupported through a reference with static type Class. BriefingScreen.as /ADAPT_PSA/src line 147 Flex Problem

Any ideas? I can get around this by compiling without strict checking b开发者_运维问答ut this seems a little clumsy...


Are you targeting and using a SDK for at least Flash Player 10.1?

When you are targeting pre Flash player 10.1, then you could get the camera and check whether or not it is null.

var camera:Camera = Camera.getCamera();
if(camera!=null) {
    // Camera is present
}

You could also check on whether or not the list of camera name is greater than zero (as each available camera is listed in this list).

if(Camera.names.length>0) {
   // At least one camera is connected
}

But again, that is only necessary for pre Flash Player 10.1

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜