I need to call a function in Flash using Javascript. For this purpose I am using ExternalInterface class(example described in the end of http://help.adobe.com/ru_RU/AS3LCR/Flash_10.0/flash/external/ExternalInterface.html). But it does not work for me.
The SWF is declared in the HTML page like this:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="305" height="270" id="DemoPlayer" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="DemoPlayer.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="DemoPlayer.swf" quality="high" bgcolor="#ffffff" width="305" height="270" name="DemoPlayer" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
I tried calling the function from Flash using Javascript:
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
}
function sendToActionScript(value) {
thisMovie("DemoPlayer").sendToActionScript(value);
}
In Flash I have:
ExternalInterface.addCallback("sendToActionScript", receivedFromJavaScript);
In FireFox I get this message: "Error calling method on NPObject! [plugin exception: Error in Actionscript. Use a try/catch block to find error.]."
I've already changed the value of the param allowScriptAccess" to "always", but it doesn't help. Maybe this is a problem with the location of ExternalInterface.addCallback("sendToActionScript", receivedFromJavaScript); it is located in the "Action-Frame" tab in the "Adobe Flash" *.fla file. (I'm new to flash).