I'm trying to call an AS3 function from Javascript via SWFObject
when i try calling i get this error
cannot call method 'js_method_to_call' of null
import flash.external.ExternalInterface;
var test_var = ExternalInterface.addCallback("js_method_to_call", moveto);
function moveto() {
gotoAndPlay(1,"Scene 2")
}
and this is my HTML file where i'm using the SWFobject
<head>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
var params = {};
var attributes = {};
attributes.id = "myFlashContent1";
swfobject.embedSWF("Test_CEO.swf", "containerid", "800", "600", "9.0.0", false, flashvars, params, attributes);
</script>
<script type="text/javascript">
function fall(){
alert("calling");
try{
var myobject = document.getElementById("containerid");
myobject.js_method_to_call();
}
catch(err) {
alert(err.message);
}
}
</script>
</head>
<body>
<div id="containerid">
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
</div>
<input id="save file" type="button" value="clickme" onclick="fall();" />
</body>
Reference : Link