I was working on something earlier today, and became so frustrated with it that I just got up and went home early for the day. I was very pleased with the work I had completed to this point, and as soon as I launched the dreaded Internet Explorer browser to ‘test compatibility’ … I immediately threw my arms up in the arm and spouted out a handful of expletives.
// …. more calls for other events
I dropped a reference to my compiled SWF onto the page using the latest SWFObject 2.0, recently released on Google Code. I even back-ported it to the last 1.5 release on blog.deconcept.com, when it failed initially … assuming, of course, that the 2.0 release was still ‘buggy’. I stood corrected.
I did some research, and found a few posts related to the issue, one that I found more or less ‘ensuring’ was Mihai Bazon’s. He basically stated that to accomplish the ExternalInterface integration to my page, I’d have to load my SWF’s with the initial page … well, this is sort of a ‘oops, would have been nice to know this AHEAD OF TIME’ thing, as it makes quite a few changes to the framework a requirement. Especially since Flash Video’s are going to be one of the driving forces to the end result.
So, with that … Mihai suggests that you can load the SWF’s dynamically still, if you load them into an IFRAME. This seems like a logical solution, but I had another alternative idea … which is to use Flash’s LocalConnection system to ‘relay’ the events, and simply loading a small lightweight ‘listening server’ on the page at ‘page load’ which can be passed the ‘destination’ and the ‘method’ with ‘arguments’. Now, to pull this off, all dynamically loaded SWF’s on the page would have to implement the same basic startup process … Which would go something like:
Pass a static param into the ‘listener server’, this represents it’s “LocalConnection Name” that it will listen on
Pass the same param into all the dynamically loaded SWF’s that will ‘attach’ to the ‘listener server’
Once the dynamically loaded SWF is done, in it’s “creationComplete” it can simply connect to the ‘listener server’ and ask to be an event handler.
Either way, I’ll probably be trying to put one of the two idea’s into practice, as it will be a required feature set for the framework I’m building.
I’ll write more about the final solution, and possibly some example code for those who may be struggling with the same issue.