[Help] of PerspectiveProjection.focalLength property says:

During the perspective transformation, the focalLength is calculated dynamically using the angle of the field of view and the stage’s aspect ratio (stage width divided by stage height).

However as far as I tested it, the stage height does not affect the result of focalLength property’s value. It is calculated from only the stage width by the following formula:

tan(fieldOfView/2) = (stageWidth/2)/focalLength
focalLength = stageWidth/2 tan(fieldOfView/2)

From [Help] of PerspectiveProjection
*From [Help] of PerspectiveProjection

focal length and field of view

focal length and field of view

Therefore the function below returns focal length by passing field of view.

// Frame action
function getFocalLength(nFieldOfView:Number):Number {
	var falf_tan:Number = Math.tan(nFieldOfView / 2 * Math.PI / 180);
	return stage.stageWidth/2/falf_tan;
}


[Note]: With Stage.scaleMode property set to StageScaleMode.NO_SCALE, the value of Stage.stageWidth property can be changed when the browser window is resized. However the PerspectiveProjection.focalLength would be calculated by the original width of the stage set with the [Property] inspector.

The revised function below can return the right result in the case:

// Frame action
var originalMode:String = stage.scaleMode;
stage.scaleMode = StageScaleMode.EXACT_FIT;
var myStageWidth:int = stage.stageWidth;
stage.scaleMode = originalMode;
function getFocalLength(nFieldOfView:Number):Number {
	var falf_tan:Number = Math.tan(nFieldOfView / 2 * Math.PI / 180);
	// return stage.stageWidth/2/falf_tan;
	return myStageWidth/2/falf_tan;
}