My actionscript 2 code in my frame 1 (called main) is as follows:
import flash.external.ExternalInterface;
ExternalInterface.addCallback('getStr', getStr);
function getStr(): String {
return "Hello World!";
}
And here is how my javascript code is trying to call it:
<!DOCTYPE html>
<html>
<head>
<script>
function getStr() {
var swf = document.getElementById("GETSTRSWF");
var str = swf.gtStr();
alert(str);
return false;
}
</script>
</head>
<body>
<a href ="#" onclick="return getStr();">Get Str</a>
<object id="GETSTRSWF" type="application/x-shockwave-flash" data="getStr.swf" width="0" height="0">
<param name="movie" value="getStr.swf" />
<param name="allowscriptaccess" value="always" />
</object>
</body>
</html>
But I get this error, and it fails:
TypeError: swf.gtStr is not a function
var str = swf.gtStr();