Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to call dynamically created flash external interface in IE from javascript?
    text
    copied!<p>What I have:</p> <ol> <li>A swf exports a function via ExternalInterface</li> <li>Javascript creates new embed object and adds it to the document</li> <li>Calling flash functions works fine in other browsers</li> <li>Calling flash functions will fail in <strong>IE 8</strong></li> </ol> <p>Example of exporting functions in swf:</p> <pre><code>flash.external.ExternalInterface.addCallback("isActive", ... </code></pre> <p>Example of creating the embed object:</p> <pre><code>var b = document.createElement('embed'); b.type = 'application\u002fx-shockwave-flash'; b.setAttribute('allowFullScreen', 'true'); b.setAttribute('allowNetworking', 'all'); b.setAttribute('allowScriptAccess', 'always'); b.width = 500; b.height = 400; b.src = 'assets\u002fUltra4.UltraApplication\u002fUltra4.UltraApplication+UltraSprite.swf'; </code></pre> <p>Example of calling flash external interface in javascript:</p> <pre><code> try { e = b.isActive(); } catch (__exc){ } </code></pre> <p>In IE it will catch with message <strong>"Object doesn't support this property or method"</strong> </p> <p>How to fix it?</p> <ol> <li>Related: <a href="http://bojolais.livejournal.com/251383.html" rel="nofollow noreferrer">http://bojolais.livejournal.com/251383.html</a></li> <li>Related: <a href="https://stackoverflow.com/questions/1166079/externalinterface-not-working-in-ie">ExternalInterface not working in IE</a></li> <li>Related: <a href="http://swfupload.org/forum/generaldiscussion/985" rel="nofollow noreferrer">http://swfupload.org/forum/generaldiscussion/985</a></li> <li>Related: <a href="http://code.google.com/p/doctype/wiki/ArticleFixingFlashExternalInterface" rel="nofollow noreferrer">http://code.google.com/p/doctype/wiki/ArticleFixingFlashExternalInterface</a></li> <li>Related: <a href="http://www.dangerouslyawesome.com/2006/10/20/another-swfobject-problem-deproblemed/" rel="nofollow noreferrer">http://www.dangerouslyawesome.com/2006/10/20/another-swfobject-problem-deproblemed/</a></li> <li>Related: <a href="http://www.airtightinteractive.com/news/?p=71" rel="nofollow noreferrer">http://www.airtightinteractive.com/news/?p=71</a></li> </ol> <hr> <p>In script debugger I can see a third party script which is supposed to be the bridge:</p> <pre><code>function __flash__arrayToXML(obj) { var s = "&lt;array&gt;"; for (var i=0; i&lt;obj.length; i++) { s += "&lt;property id=\"" + i + "\"&gt;" + __flash__toXML(obj[i]) + "&lt;/property&gt;"; } return s+"&lt;/array&gt;"; } function __flash__argumentsToXML(obj,index) { var s = "&lt;arguments&gt;"; for (var i=index; i&lt;obj.length; i++) { s += __flash__toXML(obj[i]); } return s+"&lt;/arguments&gt;"; } function __flash__objectToXML(obj) { var s = "&lt;object&gt;"; for (var prop in obj) { s += "&lt;property id=\"" + prop + "\"&gt;" + __flash__toXML(obj[prop]) + "&lt;/property&gt;"; } return s+"&lt;/object&gt;"; } function __flash__escapeXML(s) { return s.replace(/&amp;/g, "&amp;amp;").replace(/&lt;/g, "&amp;lt;").replace(/&gt;/g, "&amp;gt;").replace(/"/g, "&amp;quot;").replace(/'/g, "&amp;apos;"); } function __flash__toXML(value) { var type = typeof(value); if (type == "string") { return "&lt;string&gt;" + __flash__escapeXML(value) + "&lt;/string&gt;"; } else if (type == "undefined") { return "&lt;undefined/&gt;"; } else if (type == "number") { return "&lt;number&gt;" + value + "&lt;/number&gt;"; } else if (value == null) { return "&lt;null/&gt;"; } else if (type == "boolean") { return value ? "&lt;true/&gt;" : "&lt;false/&gt;"; } else if (value instanceof Date) { return "&lt;date&gt;" + value.getTime() + "&lt;/date&gt;"; } else if (value instanceof Array) { return __flash__arrayToXML(value); } else if (type == "object") { return __flash__objectToXML(value); } else { return "&lt;null/&gt;"; //??? } } function __flash__addCallback(instance, name) { instance[name] = function () { return eval(instance.CallFunction("&lt;invoke name=\""+name+"\" returntype=\"javascript\"&gt;" + __flash__argumentsToXML(arguments,0) + "&lt;/invoke&gt;")); } } function __flash__removeCallback(instance, name) { instance[name] = null; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload