Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4021930
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:24:43+00:00 2026-05-20T10:24:43+00:00

Goal : I want flash to have accurate information about the width and height

  • 0

Goal: I want flash to have accurate information about the width and height of the browser viewport in device pixels when intializing, resizing, or on browser zoom events.

Specifics: I need to embed flash into an html page that runs in chrome, safari, firefox, ie. The swf must fill the entire browser viewport. I don’t want the flash to zoom. Inside of flash I can set StageScaleMode.NOSCALE so that flash renders to Device Pixels. I also set the state’s alignment to StageAlign.TOP_LEFT. Now all I need is the number of device pixels in the browser!

Problem: when there is a browser zoom or I open the site while the browser is zoomed, I cannot easily get information on the browser’s dimensions in device pixels.

Solution: acrobat.com’s online document editor (formerly known as buzzword) handles this problem just fine (free to play with with an account). What are they doing? In webkit browsers, they are able to keep the document.width to report device pixels every time. I am not sure what they are doing in firefox and ie.

What doesn’t work:

  • Swffit does not support this.
  • Just loading the swf into the browser is not a solution, as the swf needs to be embedded.
  • This solution scales a swf to accomodate different browser zooms but does not get information on the browser window dimensions.

Solutions:

See selected answer below. Feedback welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:24:44+00:00Added an answer on May 20, 2026 at 10:24 am

    First a solution for webkit browsers only since it relies on document.width and document.height.

    Here is the html:

    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
    <script>
    
    function ic( )
    {   
    var params = {
    allowscriptaccess: "always",
    seamlesstabbing: "false",
    menu: "false"
    };
    var flashvars = {
    bzw: document.width,
    bzh: document.height
    };
    swfobject.embedSWF( "bZoom.swf", "b",
    "100%", "100%",
    "10", null, flashvars, params, {} );
    Event.observe( window, 'resize', rs.bindAsEventListener(this) );
    }
    
    function rs( )
    {
    getFlash("b").JS2AS_resize( document.width, document.height );
    }
    
    function getFlash( id )
    {
    if (navigator.appName.indexOf("Microsoft") != -1)
    {   return window[id];
    }
    else
    {   return document[id];
    }
    }
    
    Event.observe( window, 'load', ic.bindAsEventListener(this) );
    </script>
    </head>
    <body style="margin:0;padding:0;">
    <div id="a" style="position:absolute;top:0;left:0;width:100%;height:100%;"><div id="b"></div></div>
    </body>
    </html>
    

    Here is the as3:

    package
    {
    import flash.display.LoaderInfo;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.external.ExternalInterface;
    
    public class bZoom extends Sprite
    {
    
    private var _w:int;
    private var _h:int;
    
    
    public function bZoom( ):void
    {
        var lobj:Object = LoaderInfo( this.root.loaderInfo ).parameters;
        _w = lobj["bzw"];
        _h = lobj["bzh"];
        ExternalInterface.addCallback( "JS2AS_resize", JS2AS_resize );
    
    
        stage.align = StageAlign.TOP_LEFT;
        stage.scaleMode = StageScaleMode.NO_SCALE;
        painty( );
    }
    
    public function JS2AS_resize( pw:int, ph:int ):void
    {   _w = pw;
        _h = ph;
        painty( );
    }
    
    public function painty( ):void
    {
        graphics.clear();
        graphics.beginFill( 0xFFFFFF );
        graphics.drawRect( 0, 0, _w, _h );
        graphics.beginFill( 0xFF0000 );
        graphics.drawRect( 0, 0, _w-5, _h-5 );
    }
    
    }
    }
    

    And here is a solution for IE, Mozilla, and Opera:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" style="overflow-y:hidden;overflow-x:hidden;">
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
    <script>
    
    function ic( )
    {   
    var params = {
    allowscriptaccess: "always",
    seamlesstabbing: "false",
    menu: "false"
    };
    var dv = document.viewport;
    swfobject.embedSWF( "bZoom.swf", "b",
    dv.getWidth()+"px", dv.getHeight()+"px",
    "10", null, flashvars, params, {} );
    Event.observe( window, 'resize', rs.bindAsEventListener(this) );
    }
    
    function rs( )
    {
    var dv = document.viewport;
    var dvw = dv.getWidth();
    var dvh = dv.getHeight();
    $("b").width = dvw+"px";
    $("b").height = dvh+"px";
    //for reasons unknown (...timing?) we ask for these again
    var dvw = dv.getWidth();
    var dvh = dv.getHeight();
    getFlash("b").JS2AS_resize( );
    }
    
    function getFlash( id )
    {
    if (navigator.appName.indexOf("Microsoft") != -1)
    {   return window[id];
    }
    else
    {   return document[id];
    }
    }
    
    Event.observe( window, 'load', ic.bindAsEventListener(this) );
    </script>
    </head>
    <body style="margin:0;padding:0;background-color:#00FF00;">
    <div id="a" style="position:absolute;top:0;left:0;"><div id="b"></div></div>
    </body>
    </html>
    

    and the as3:

    package
    {
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.external.ExternalInterface;
    
    public class bZoom extends Sprite
    {
    
    
    public function bZoom( ):void
    {
    
        ExternalInterface.addCallback( "JS2AS_resize", JS2AS_resize );
    
        stage.align = StageAlign.TOP_LEFT;
        stage.scaleMode = StageScaleMode.NO_SCALE;
        painty( );
    }
    
    
    public function JS2AS_resize( ):void
    {   painty( );
    }
    
    public function painty( ):void
    {
        graphics.clear();
        graphics.beginFill( 0xFFFFFF );
        graphics.drawRect( 0, 0, stage.stageWidth, stage.stageHeight );
        graphics.beginFill( 0xFF0000 );
        graphics.drawRect( 0, 0, stage.stageWidth-5, stage.stageHeight-5 );
    }
    
    }
    }
    

    Finally, I believe there is a more optimal solution for Opera using screen.width and screen.height, but I’ve not tested it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

goal: I have the string 1234432144 I want to only replace the first 2
I have the pages that I want to set as a goal in Google
I have some questions regarding my MVC learning curve Goal: I want to get
I have a relatively simple goal: I want to create a Cocoa application which
I have a simple question that is confusing me. Goal : I want to
goal : I want to place a text after the submit button using hook_form_alter.
My Goal: i want to create an horizontal list of images. when mouse is
I've recently started my new private project. The main goal which I want to
I want to extract kernel symbols from a u-boot image The final goal is
My goal here is to make a button. I want the text to sit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.