Firefox 3 Mac Flash Bug stageWidth and stageHeight are 0

January 20th, 2009 by Steven Sacks

Yet another issue with Firefox 3 on the Mac and the Flash player. Flash cannot detect the stage.stageWidth and stage.stageHeight on fixed sized swfs in Firefox 3 on OSX. According to Flash, they are 0,0. You can imagine what this kind of problems this causes. Any code that relies on the width and height of the stage, such as layout and sizing, fail on Firefox 3 on OSX.

Here you can see it in action. Open this page in any browser other than Firefox 3 on OSX and Flash correctly shows the stage.stageWidth and stage.stageHeight.

http://www.stevensacks.net/flashbugs/stage/index.html

Here's the source.

Waiting until ADDED_TO_STAGE to fire doesn't help, as shown here:

http://www.stevensacks.net/flashbugs/stage/index2.html

Here's the source.

The reality of the situation is that in Firefox 3 on OSX, the stage.stageWidth and stage.stageHeight are not available for MULTIPLE frames, as shown here. If it loads cached, it's one frame. If you clear your cache, I've seen it take up to EIGHT FRAMES before stageWidth and stageHeight are not 0.

http://www.stevensacks.net/flashbugs/stage/index3.html

Here's the source.

So the question is who is responsible? Is it Firefox 3 or is the Flash player?

Update: Apparently, this is an issue on Win/IE, as well.

http://hubflanger.com/stage-resize-and-the-stagewidth-and-stageheight-properties/

Posted in Adobe, Bugs, Firefox, Flash

18 Responses

  1. Mike Keesey

    All three work fine for me. FF 3.0.5, FP 10 (debugger), OSX 10.5.6

  2. Ryan Hovland

    I've seen this before too. Pretty crappy. As a workaround I think I just set an onEnterFrame listener or interval and cleared it once something other than zero came back.

  3. Steven Sacks

    Everyone in my office sees 0,0, even the people who have zero plug-ins.

  4. alban

    Same config than Mike keesey and I can see stageWidth and Height in your exemple.
    Try to set "noflash" as id parameter in your swfObject call, to have your flash object wrapped inside a div.

  5. Josh Tynjala

    I've seen many SWFs across the web recently where all the content seems to be stuck in the top-left corner. It's probably related since I'm using FF3 on a Mac.

    In the past, I've seen this issue on Windows machines, which you noted in the update. The best solution I found for that problem (it may not work here) is to always listen for Event.RESIZE if you need to do any sort of calculations using the stage size. Do your sizing once right away when the SWF is initialized, but also listen for the resize event, just in case stageWidth and stageHeight were zero.

  6. Anthony Graddy

    This has been a problem with IE7 too. You can vote on the bug here:
    http://bugs.adobe.com/jira/browse/FP-434

    The more people who vote, hopefully the more likely we are to see this bug get fixed (if it's Adobe's problem).

  7. vitaLee

    everything works fine for me too.
    FF 3.0.5 on MAC 10.5

  8. corbanb

    i'm seeing what you guys are here as well.

    Fist two examples show 0,0.

    The third seems fine.

    Does it have anything to do with FP Version like debug player etc?

  9. tomd51

    I was seeing this exact behavior on my Firefox 3.0.5 build on my PC laptop. I am running several plug-ins, which included Adblock 0.5.3.043 as well as Adblock Plus 1.0.1. In my disabling/enabling of plug-ins, I found that Adblock 0.5.3.043 caused this behavior in a completely reproducible manner, regardless of whether I whitelisted the page and site or not. Easily reproducible with both the Weather Channel new local map and the stageWidth/stageHeight page Steven has created.

    Disabling this plug-in and substituting Adblock Plus instead alleviates this problem completely. Just an FYI to those that might be seeing this behavior and using that FF plug-in…

  10. erikbianchi

    I've hit this issue on windows running Flash 9 in the past. I just took it as a flash quirk and coded around it using enterframe like you last sample.

    not sure who to blame or if there is another fix.

    -erik

  11. badhouse

    works fine in FF3 for me too [ 10.5.5 ]

  12. jed

    aral balkan had a similar issue that he attributes to swfobject (rather than FF or the flash player in isolation), which i note that you're using in your example pages.

    http://aralbalkan.com/1933

  13. Steven Sacks

    Thanks for the heads up, Jed! And thanks to Aral for delving deeper than I did. :)

  14. bobby

    I have added this issue to the SWFObject FAQ (Q21):
    http://code.google.com/p/swfobject/wiki/faq

  15. Terry

    Ughhh. This is why I hate Information Technology.

    I was sizing my chromeless player based on Stage.width, unaware that zero was lurking in the chaos.

    I added FlashVars to my AC_RunActiveContent duplicating width and height so I can always get my default stage size, regardless of bunk global variables.

    I just spent weeks debugging a Flash quirk. Good luck in HTML5, oh mighty ubiquitous plug-in.

  16. pleb

    yeah this is a major pain. the problem occurs about 20% of the time in FF3 when trying to capture the stage dimensions after an ADDED_TO_STAGE event.

  17. Josh Noble

    Thanks for putting this out there. After reading this I've made a simple JS function which I can call from flash (if the stage.stageWidth comes back as 0) which gives me the divs width and height which seems to work great.

  18. Rich Hauck

    Thanks for posting this. I revisited an old site that was bugging out and I was going crazy thinking how I could have left such a bug.

    Fortunately, my site isn't so dependent on the stage size changing. Has anyone tried referencing displayObject.parent.width ?

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

About Steven Sacks

I am a professional Flash developer with over 13 years of programming experience. I have consulted for high-profile agencies and companies in San Francisco, Los Angeles, Atlanta and New York, and developed numerous award-winning websites and rich internet applications for clients including Adobe, Fox Sports, FX Networks, Anheuser-Busch, GE, DirecTV, ESPN, The Weather Channel, Home Depot, and Coca-Cola.

I am the author of the open-source Gaia Framework for Adobe Flash, which dramatically reduces development time and makes developing Flash sites much easier.