another swfobject problem, deproblemed
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.



29. January 2007 at 11:33
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!
14. June 2007 at 09:45
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.
22. June 2007 at 21:41
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?
23. June 2007 at 07:24
@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.