Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Trying to call an external function

New Here ,
Aug 02, 2018 Aug 02, 2018

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!

608
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 02, 2018 Aug 02, 2018

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();

Translate
Community Expert ,
Aug 02, 2018 Aug 02, 2018

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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 02, 2018 Aug 02, 2018

Are you working in AS3 or HTML5 Canvas?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 02, 2018 Aug 02, 2018

Doing this on HTML Canvas

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 02, 2018 Aug 02, 2018

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();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 02, 2018 Aug 02, 2018
LATEST

Thank you for the explanation.

Will give this a go.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines