erikvold
erikvold

Reputation: 16508

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

In my actionscript file I have:

ExternalInterface.addCallback("loadHotspotsXMLCallback", 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:

But these changes had no effect.

Upvotes: 1

Views: 5985

Answers (3)

kroe
kroe

Reputation: 1126

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

Upvotes: 0

meder omuraliev
meder omuraliev

Reputation: 186562

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.

Upvotes: 3

kim3er
kim3er

Reputation: 6466

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

Upvotes: 1

Related Questions