Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Why does Camera.getCamera(camName); always returns null

Avatar

Former Community Member

Why would the camera instance be null, if the Camera class knows the name of the Camera !!

for each (var camName:String in Camera.names) {

                   

                    var camera:Camera = Camera.getCamera(camName);

                   

                    trace("Camera = " + camera);

                   

                 

                    if(camName.indexOf("Front") != -1){

                            cameraIndex = camera.index; //: Causes a null exception to be thrown.

                       

                    }

}

1 Reply

Avatar

Former Community Member

You need to use camera index in string type instead of camera name.

var camera:Camera = Camera.getCamera("0"); //or "1" for front camera