Code Snippets : Solving Flash loading problem with WMode and Firefox

I’ve recently experienced problems on few AS3 websites. If you embed your SWF file with different WMode, like opaque or transparent in Firefox your Flash won’t load. Actually the Flash loads first frame and then it seems like it stops. Well, it certainly loads but the problem is that loaderInfo Event.COMPLETE and PROGRESS are not fired in Firefox.

That is LAME! Firefox has this “advanced” feature with Flash, it doesn’t load it until that browser tab has focus. Seems like we’re getting problem from there. Anyway, a workaround is to set the Event.ENTER_FRAME function that will check loader

addEventListener(Event.ENTER_FRAME, _listenLoading);// on enter frame to check if it’s loaded
private function _listenLoading(e:Event):void {
  if (this.loaderInfo.bytesLoaded == this.loaderInfo.bytesTotal) {
    removeEventListener(Event.ENTER_FRAME, _listenLoading);
    _onSiteLoaded();
  }
}
About these ads

9 Responses to “Code Snippets : Solving Flash loading problem with WMode and Firefox”


  1. 1 M June 19, 2009 at 4:11 am

    Thanks! This info was very helpful to me. :)

  2. 2 Og2t June 23, 2009 at 4:11 pm

    Thanks! Good to know. There’s another problem with the stage dimensions and FF3. Shortly after the SWF loads, the stage.stageWidth and stage.stageHeight are both equal zero. That could be a problem i.e. when centering the preloader. The fix is simple:

    private function checkStageDimensions():void
    		{
    			if (!stageRef.stageWidth || !stageRef.stageHeight)
    			{
    				if (stageCheckCount < 10) setTimeout(checkStageDimensions, 100);
    				stageCheckCount ++;	
    			} else {
    				addProgressCheck();
    			}
    		}
    
  3. 3 craigk July 21, 2009 at 1:40 pm

    Thanks for that mate, very useful bit of code there.

  4. 4 sherest July 31, 2009 at 2:06 pm

    thanks! i faced the same problem, but your this useful information helps me out.

    thanks a lot.

    regards
    Sherest

  5. 6 Joey van Dijk September 15, 2009 at 7:42 pm

    This is indeed a bummer, but it has the same issues with IE7/IE8 but then stageWidth=0, so workarounds can be an enterframe like you said or use ADD-events. More info/workarounds at https://bugs.adobe.com/jira/browse/FP-434 and https://bugs.adobe.com/jira/browse/FP-2641.

    Really too bad that some of the most basic parts of the Flash Player differ between browsers.
    :(

  6. 7 gabe November 19, 2009 at 3:26 am

    Ran into a similar issue that Og2t mentioned. If my swfs (multiple embedded video players) weren’t immediately visible in Firefox, their stage was 0. Solution was to use the Event.ENTER_FRAME listener to check the values of stage.stageWidth and stage.stageHeight before I ran any resizing functions which depended on accurate stage values.

  7. 8 DostavkaTovarov January 24, 2011 at 7:27 am

    Доставка любых товаров, грузов и оборудования из Китая по всей России, таможенная очистка и сертификация. Объем от 10 куб.м. или вес от 2т. Многолетний опыт, оптимальные цены и сроки. 100% официально и надёжно! Ваш № телефона на почту или майл-агент dostavkatovarovСОБАКАmail.ru, или на ICQ 271-272-525 и мы Вам позвоним!

  8. 9 anthony leicher March 12, 2011 at 12:45 am

    Hello, I figured this was a timing issue since FireFox seemed to be killing my events somehow… This is a good workaround and I recommend it to anyone having the same problem. Thank you very much for posting this.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s




Info

Blog of Aleksandar Gvozden Technical director of MADEBYPLAY

Welcome and enjoy... more updates coming soon!

Catch me on
Twitter
LinkedIn
Facebook


CU3ER - 3D Image Slider

Twitter

Tags


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: