First and foremost, if you want to communicate from Flex to (regular) Javascript using ExternalInterface in Internet Exploder (I was testing on version 6), you had better put an id attribute on the [object] and [embed] elements, or else it will either silently fail, or give you the wonderfully descriptive and logical error message 'null' is null or not an object. If I didn't know any better, I'd say it's rather philosophical. Oh, and it's always at character 118, line 1. I dare you to find it :)
You find this information if you read the first note on the Adobe documentation page for ExternalInterface.
When I said 'regular' earlier, I meant javascript that's already embedded in the page. Now, if you want to do nifty stuff like Javascript injection, you would probably use Abdul Qabiz's fantastic component. The reason I needed it was that our Flex application needed to be completely independent of the html wrapper it happened to find itself in, but also needed to open IFrames and move them around and do all kinds of nifty stuff (you can tell I like this word). That meant that the script would have to be embedded at runtime in the page by Flash.
Sounds doable, right? In Firefox, yes. In IE, haha, you've got another thing coming. IE and 'simplicity' have proven to be at opposite ends of the spectrum, time and time again.
I won't drone on about the specifics too much. But here are some major points to keep in mind:
- for IE6 at least, only use double quotes only in the JavaScript file you are loading. If not - you guessed it - it silently fails.
- don't try to use document.createElement("iframe"), because apparently there is a bug in IE for this particular function with this particular argument (read the first comments, where you will also find the workaround).
No comments:
Post a Comment