Copy link to clipboard
Copied
Hello,
I have been trying to figure out how to call an external function on my Animate project.
this is the code I am using, but it seems like ExternalInterface. is not supported...
this.closeCTA.addEventListener("click", windowClose);
function windowClose(){
ExternalInterface.call("hideAnimation");
}
Any help would be greatly appreciated
Thanks!
Okay, there is no ExternalInterface in Canvas mode because there is no plugin to externally interface with. Published Canvas documents run as bare-metal JavaScript directly in the browser, just like all the other JavaScript programs on the web.
So if a JS function is defined outside of Animate in the global scope, to call it you just... call it:
hideAnimation();
Copy link to clipboard
Copied
your embedding html has to have compatible code.
test with this:
<!-- saved from url=(0014)about:internet -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>yourswf</title>
<script language="JavaScript">
function hideAnimation() {
alert('called');
}
</script>
</head>
<body>
</body>
<object id="yourswf" name="yourswf"
type="application/x-shockwave-flash" data="yourswf.swf" width="550" height="400">
<param name="movie" value="yourswf.swf"/>
<param name="quality" value="high"/>
<param name="allowscriptaccess" value="always"/>
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/>
</a>
</html>
Copy link to clipboard
Copied
Are you working in AS3 or HTML5 Canvas?
Copy link to clipboard
Copied
Doing this on HTML Canvas
Copy link to clipboard
Copied
Okay, there is no ExternalInterface in Canvas mode because there is no plugin to externally interface with. Published Canvas documents run as bare-metal JavaScript directly in the browser, just like all the other JavaScript programs on the web.
So if a JS function is defined outside of Animate in the global scope, to call it you just... call it:
hideAnimation();
Copy link to clipboard
Copied
Thank you for the explanation.
Will give this a go.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now