Skip to main content
Participant
August 2, 2018
Answered

Trying to call an external function

  • August 2, 2018
  • 3 replies
  • 676 views

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!

    This topic has been closed for replies.
    Correct answer ClayUUID

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

    3 replies

    boshunterAuthor
    Participant
    August 2, 2018

    Doing this on HTML Canvas

    ClayUUIDCorrect answer
    Legend
    August 2, 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();

    boshunterAuthor
    Participant
    August 2, 2018

    Thank you for the explanation.

    Will give this a go.

    Legend
    August 2, 2018

    Are you working in AS3 or HTML5 Canvas?

    kglad
    Community Expert
    Community Expert
    August 2, 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>