another swfobject problem, deproblemed

Uncategorized 20 October 2006 | View Comments

flash/rich HTML coexisting is definately turning up a whole new, fun set of challenges. So far, some of my favorites are: * having rich modal windows appear behind flash elements (fixable using the iframe shim technique) * setting focus of various elements (fixed by creating a variable in our base page class that let me set the default focus to any elment by ID) * today’s, having to do with the ExternalInterface.AddCallback method in flash, and its playing nice with swfobject.

In essence, we have a login function that pops up one of those nifty DHTML layers with a login box. Our top navigation is all flash, and has a login call to action…so having flash call javascript functions isnt hard, but getting javascript to “poke” at the flash and have it run an internal function is a bit trickier. Utilizing the aforementioned callback method, its fairly simple. The problem we had was, in Internet Explorer, order of operations was a bit out of whack.

we got an error on: __flash__addCallback(coreLoader, "loginNav"); coming from INSIDE the flash…what seemed to be happening was the javascript that set up the object “coreLoader” wasnt running at the right time because of the time it took for swfObject to set up the embed. So, adding coreLoader = $('coreLoader'); immediately AFTER so.write("topNav"); set up the object again, this time not filling the object with a null (because swfObject had correctly identified an embed with id=coreLoader), and allowing the internal flash “addCallback” function to work.

hm, technical writing is difficult. but i felt the need to document this problem (even if it wasnt very well) for my own future reference, and hopefully someone else will find it handy as well.

the more general moral of the story is: pay attention to order of operations, they may save your life some day.

Bookmark and Share

Tagged in , ,

  • Tim
    Hey -- Question. I thought this worked for me, but it didnt.
    is this line: "coreLoader = $('coreLoader');" referring to jQuery's $() ?
  • Tim
    that really was dangerously amazing. you saved me probably an hour+ of hacking and cursing at the piece of sh*t they call ie. thx again.
  • meenkanni
    Thanks. Your description is not particularly clear, but I implemented the fix and it works.
  • @Jamie,
    For it to work, and then not, sounds like an old version of your scripts are being cached. Other than that, without looking I'm not sure I can be much more help to you.

  • We seem to be getting the same error message in IE6. I did your fix, and it worked, however I went back a few minutes later and the same thing came up... any suggestions?

  • David Zhao

    Hey, just wanted to say thanks for documenting this. I was kicking myself wondering what the problem was with IE/SWFObject. This should be brought to attention to the SWFObject guys.

  • Ben Long

    I'm curious about your approach for debugging errors with __flash__addCallback. Can you please email me at shift.insert[at]gmail[dot]com? I'm not looking for you to debug for me, but possibly shed some insight into debugging methods.


    Thanks!

blog comments powered by Disqus