开发者

Flash & IE : “Object doesn’t support this property or method” error (using ExternalInterface)

开发者 https://www.devze.com 2023-02-14 12:59 出处:网络
In my actionscript file I have: ExternalInterface.addCallback(\"loadHotspotsXM开发者_C百科LCallback\", hotspotsXMLCallback);

In my actionscript file I have:

ExternalInterface.addCallback("loadHotspotsXM开发者_C百科LCallback", hotspotsXMLCallback);

In html I have:

<embed width="100%" height="100%" align="middle" type="application/x-shockwave-flash" salign="" allowscriptaccess="sameDomain" allowfullscreen="false" menu="false" name="FloorplanViewer" bgcolor="#FFFFFF" id="FloorplanViewer" devicefont="false" wmode="transparent" scale="showall" loop="false" play="true" pluginspage="http://www.adobe.com/go/getflashplayer" quality="high" flashvars="..." src="swf/FloorplanViewer_V110228b.swf">

In JS I have:

$("FloorplanViewer")["loadHotspotsXMLCallback"](response.responseText);

And I've also tried:

window["loadHotspotsXMLCallback"](response.responseText)

and

document["loadHotspotsXMLCallback"](response.responseText)

But the JS part DNW in IE, and it does in FF and GC. Does anybody know why?

I've read this documentation on using ExternalInterface, and while my problem is occuring for IE8, I tried the follwing suggested IE7 solutions mentioned there:

  • making sure that the added external callback name is not the same as the internal callback name for the actionscript code above.
  • delaying the code that adds the callback by 500ms

But these changes had no effect.


I suggest trying it as simple as possible from my article, http://work.arounds.org/issue/10/calling-flash-functions-from-javascript/

<object id="flash" data="file.swf" width="420" height="300"></object>
<script>
      onload = function() {
          var flash = document.getElementById('flash');
          flash.NextFrame();
      }
</script>

First try converting your embed to an object, then just a simple get element by ID after window load. Also try alert( 'functionName' in flash ); to make sure the method exists.


I would try something like this:

var fpViewer = document["FloorplanViewer'] || window["FloorplanViewer"];
fpViewer.loadHotspotsXMLCallback(response.responseText);

Also, I lose track on what the best practice is for inserting Flash into pages nowadays. But I'd definitely wrap that embed element with an object element, to ensure maximum cross browser compatibility.

Rich


I had a really hard time solving problems like that with IE 6, 7, 8, etcs..

Some things that helped, in order of priority:

  1. delaying the code that CALLS the callback

  2. If you have more than 1 SWF using that, try not to attach all the SWF files that adds callbacks/etcs at the same time

Two or more concurrent javascript calls ( addCallbacks / ExternalInterface.call / etcs ) normally results in some IE fail.

If you need to do many javascript calls, may be is the case to implement a "Javascript call stack" that will call each operation after another one with a little delay.

really hope it helps

i had really bad times struggling with IE / cross-browser compatibility with more than 1 swf file in the same page needing control from/to javascript

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号