Groups | Blog | Home
all groups > flash actionscript > november 2007 >

flash actionscript : exernalInterface (argh!)



jmoggio
11/2/2007 7:50:47 PM
I managed to get my flash to call an external js function successfully, but
can't get a js function to call back in. Hoping I'm just missing some dumb
little thing. I've looked at a bunch of samples and can't figure it out...

Flash movie name, id in the HTML is listenInLibraryPlayer
In the Flash movie, I have...

import flash.external.*;
function newMedia(idNumber){
testText.htmlText = idNumber;
}
ExternalInterface.addCallback("sendID", null, newMedia);


In the HTML head I have code I got from adobe.com...

<SCRIPT LANGUAGE=JavaScript>
function callExternalInterface() {
getMovieName("listenInLibraryPlayer").sendID(str);
}

function getMovieName(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName]
}
else {
return document[movieName]
}
</script>


In the HTML body I have...

<form name="inputValue">
ID Number <input type="text" name="x" size="10" >
Enter 1 or 2.
</form>
<form>
<input type="button" onClick="callExternalInterface()" value="Call Flash
Function" />
</form>
kglad
11/2/2007 9:50:34 PM
jmoggio
11/2/2007 9:54:37 PM
That is the name of the .swf.

I have no idea about the HTML and the javascript - I just took some code from
a sample.

I have a new version which uses links instead of a form (and also fails, but
is closer to what I eventually want)...

<a name="text_link" id="text_link" onclick='callExternalInterface("1");'
[quoted text, click to view]

<a name="text_link" id="text_link" onclick='callExternalInterface("2");'
[quoted text, click to view]




GWD
11/2/2007 10:36:27 PM
if your object tag id atttribute is "listenInLibraryPlayer" and the embed tag
name attritbute is also "listenInLibraryPlayer"
then try this from javascript:

getMovieName("listenInLibraryPlayer" ).callExternalInterface("1");
AddThis Social Bookmark Button