ExternalInterfaceFunction is not a function

210 views
Skip to first unread message

Prabu Singhular

unread,
Mar 21, 2008, 9:20:21 PM3/21/08
to SWFObject
In using SWFObject 2.0's object static-method, Firefox & IE are unable
to call AS functions from javascript.

<object id="MySWF" classid="clsid:D27CDB6E-
AE6D-11cf-96B8-444553540000" width="100%" height="100%">

var mySWFMovie=document["MySWF"];
mySWFMovie.ExternalInterfaceFunction(somevalue);

//returns the javascript TypeError: mySWFMovie.
ExternalInterfaceFunction is not a function

Any ideas on why this is occuring? Is there another syntax for
calling functions on HTMLObjectElement's, than there is for
HTMLEmbedElement's?

Prabu Singhular

unread,
Mar 21, 2008, 9:35:02 PM3/21/08
to SWFObject
If I add an embed tag, and target this EmbedElement, it works....It's
just not clear to me why Geoff is avoiding using the Embed tag, and
whether there's a better way I should be doing this. Any thoughts?

<embed src="TheMovie.swf" quality="high"
width="100%" height="100%" name="MySWF"
type="application/x-shockwave-flash"
</embed>

Prabu Singhular

unread,
Mar 21, 2008, 9:37:20 PM3/21/08
to SWFObject
<embed src="TheMovie.swf" quality="high"
width="100%" height="100%" name="MySWF"
quality="high" allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/
getflashplayer">
</embed>



On Mar 21, 6:20 pm, Prabu Singhular <singh...@gmail.com> wrote:

Bobby

unread,
Mar 22, 2008, 5:47:08 AM3/22/08
to SWFObject
Why we don't use the embed element: http://www.alistapart.com/articles/flashembedcagematch/

And scripting does work: http://www.swffix.org/swfobject/testsuite/test_com.html
Please study its source code: are you sure you used the nested objects
method, or did you use a single object? Also make sure to set the
correct attributes and param elements for both elements.
Message has been deleted
Message has been deleted

Prabu Singhular

unread,
Mar 22, 2008, 1:57:38 PM3/22/08
to SWFObject
Thanks Boddy, my HTML/Javascript looks proper. I would think there's
a problem with my Flash Movie, except that it works if I use the embed
tag. I also thought perhaps, javascript is simply trying to call the
AS function before the SWF is loaded, but if I call the function on a
scroll event, and scroll once the SWF is loaded, I get the same 'no
External Interface function' error message.

<link rel=StyleSheet type="text/css" href="../resources/css/
style.css" />
<script type="text/javascript" src="../resources/scripts/
browserDetect.js"></script>
<script type="text/javascript" src="../resources/test/swfobject.js"></
script>
<script type="text/javascript">
swfobject.registerObject("MySWF", "9.0.45", "../resources/
test/
expressinstall.swf");
var obj = swfobject.getObjectById("MySWF");
if (obj && typeof obj.ExtInterfaceScroller != "undefined") {
alert('External Interface available');
} else {
alert('no External Interface function available');
}
</script>
<script type="text/javascript" src="../resources/scripts/
resize2.js"></
script>
</head>

<body>
<div id="ONE">
<object id="MySWF" classid="clsid:D27CDB6E-
AE6D-11cf-96B8-444553540000" width="100%" height="100%">
<param name="movie" value="One.swf" />
<param name="allowScriptAccess"
value="sameDomain" />
<!--[if !IE]>-->
<object name="MySWF" type="application/
x-shockwave-flash"
data="One.swf" width="100%" height="100%">
<!--<![endif]-->
<div><p align="center"><br /
><br /><br />-- Requires Adobe Flash
Player 9.0.45 or higher --<br /><br /><a href="http://www.adobe.com/
go/
getflashplayer"><img src="../resources/images/getFlash.gif" alt="Get
Flash Player" width="112" height="33" /></a></p></div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
<div id="SCROLLER">
<div id="FHEIGHT">
</div>
</div>

</body>
</html>

Bobby

unread,
Mar 22, 2008, 4:54:56 PM3/22/08
to SWFObject
Just use swfobject.addLoadEvent to add a function to call:

var obj = swfobject.getObjectById("MySWF");
...

This because your external interface code will only be available after
your flash content has loaded and initialized. Just check the source
code of: http://www.swffix.org/swfobject/testsuite/test_com.html
Message has been deleted
Message has been deleted
Message has been deleted

Prabu Singhular

unread,
Mar 22, 2008, 5:37:26 PM3/22/08
to SWFObject
Hmmm, even calling the External Interface function within the
swfobject.addLoadEvent event handler doesn't work.


function setJSObjects()
{
var obj = swfobject.getObjectById("MySWF");

if (obj) {
//alert('External Interface available');
try
{
obj.ExtInterfaceScroller(10);
} catch(err)
{
alert(err);
};
} else {
alert('no External Interface function available');
}

}
swfobject.addLoadEvent(setJSObjects);
Message has been deleted

Prabu Singhular

unread,
Mar 22, 2008, 5:53:33 PM3/22/08
to SWFObject
So, I tried removing my swf and using SWFObject's test8_com swf, with
it's JStoASviaExternalInterface function. Which worked. So it must
be some incompatibility with my flash movie. Which oddly enough
functions properly if I use the embed tag, or SWFObject 1.5.

Prabu Singhular

unread,
Mar 26, 2008, 9:00:27 PM3/26/08
to SWFObject
UPDATE RESOLUTION;

It was a scoping issue. I was trying to assign a javascript variable
referencing a DIV element within the html body. I moved it to the
LoadEvent, and presto bango we're in action. So far so good.

Thank you again Bobby for your direction!
Reply all
Reply to author
Forward
0 new messages