mardi 11 avril 2017

How to get browser zoom factor to work?

I'm trying to determine if a user has zoomed in on their web page and it looks like there are a few properties that are available to help determine this one of them being the stage.browserZoomFactor. Nothing I've tried is changing the value. It is always 1.

Here is the code I'm using:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="" 

               minWidth="955" minHeight="600" 


            protected function getZoomInfo():void {
                var clientWidth:int;
                var scaleFactor:Number

                if (ExternalInterface.available) {
                    ExternalInterface.marshallExceptions = true;
                    clientWidth =, ExternalInterface.objectID);
                    scaleFactor = Number(Number(stage.stageWidth/clientWidth).toFixed(1));

                zoomFactorLabel.text = "";
                zoomFactorLabel.text += "Client width: "+clientWidth + "\n";
                zoomFactorLabel.text += "Stage width: "+stage.stageWidth + "\n";
                zoomFactorLabel.text += "Calculated Scale factor: "+scaleFactor + "\n";
                zoomFactorLabel.text += "Browser Zoom factor: "+stage.browserZoomFactor + "\n";
                zoomFactorLabel.text += "Content Scale Factor: "+stage.contentsScaleFactor + "\n";
                zoomFactorLabel.text += "DPI: "+applicationDPI;

            protected function application1_applicationCompleteHandler(event:FlexEvent):void {
                stage.addEventListener(Event.BROWSER_ZOOM_CHANGE, browserZoomChange);

            protected function browserZoomChange(event:Event):void {
                trace("Zoom changed");
                zoomFactorLabel.text = "Zoom changed";


        <fx:String id="string"><![CDATA[
function(clientId) {
    var clientWidth = document.getElementById(clientId).clientWidth;
    return clientWidth;

    <s:TextArea id="zoomFactorLabel" horizontalCenter="0" verticalCenter="-60"/>
    <s:Button label="check browser zoom" click="getZoomInfo()" horizontalCenter="0" verticalCenter="30"/>


I've also set the browserzoom to scale and noscale in the HTML wrapper page. And neither option seems to do anything. Browser zoom is supposed to be enabled by default.

If I manually get the swf object client width I can compare it to the stage width and get a scale factor but doesn't work in Firefox (on Mac) it does work on Safari (on Mac).

  • Adobe Blog post on browser zoom factor.
  • Release notes on Flash Player 21.

Aucun commentaire:

Enregistrer un commentaire