dimanche 11 mai 2014

ActionScript 3 - erreur de compilation à l'aide de Camera.isSupported - Stack Overflow


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 but 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



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 but 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 commentaires:

Enregistrer un commentaire