Skip to main content
Participating Frequently
October 19, 2010
Answered

Calling AS3 Function from Javascript

  • October 19, 2010
  • 1 reply
  • 1587 views

import flash.external.*;
flash.system.Security.allowDomain('http://localhost');

function funcFlash()
{

    //SoundMixer.stopAll();
}
ExternalInterface.addCallback("funcJS", funcFlash);

But I got errors when play it(swf file) after publishing:

Error: Error #2067: The ExternalInterface is not available in this container. ExternalInterface requires Internet Explorer ActiveX, Firefox, Mozilla 1.7.5 and greater, or other browsers that support NPRuntime.
at Error$/throwError()
at flash.external::ExternalInterface$/addCallback()
at xxxx........._fla::MainTimeline/frame1()

Please help, thanks.

Flashplayer 10, XP pro.

This topic has been closed for replies.
Correct answer

Do you have this tag in your html:

<param name="allowScriptAccess" value="sameDomain" />

Example:

<div id="flashContent">
   <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="keypress" align="middle">
    <param name="movie" value="keypress.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#ffffff" />
    <param name="play" value="true" />
    <param name="loop" value="true" />
    <param name="wmode" value="window" />
    <param name="scale" value="showall" />
    <param name="menu" value="true" />
    <param name="devicefont" value="false" />
    <param name="salign" value="" />
                <param name="allowFullScreen" value="true" />
    <param name="allowScriptAccess" value="sameDomain" />
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="keypress.swf" width="550" height="400">
     <param name="movie" value="keypress.swf" />
     <param name="quality" value="high" />
     <param name="bgcolor" value="#ffffff" />
     <param name="play" value="true" />
     <param name="loop" value="true" />
     <param name="wmode" value="window" />
     <param name="scale" value="showall" />
     <param name="menu" value="true" />
                    <param name="allowFullScreen" value="true" />
     <param name="devicefont" value="false" />
     <param name="salign" value="" />
     <param name="allowScriptAccess" value="sameDomain" />
    <!--<![endif]-->
     <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>
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
   </object>
  </div>

1 reply

Correct answer
October 19, 2010

Do you have this tag in your html:

<param name="allowScriptAccess" value="sameDomain" />

Example:

<div id="flashContent">
   <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="keypress" align="middle">
    <param name="movie" value="keypress.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#ffffff" />
    <param name="play" value="true" />
    <param name="loop" value="true" />
    <param name="wmode" value="window" />
    <param name="scale" value="showall" />
    <param name="menu" value="true" />
    <param name="devicefont" value="false" />
    <param name="salign" value="" />
                <param name="allowFullScreen" value="true" />
    <param name="allowScriptAccess" value="sameDomain" />
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="keypress.swf" width="550" height="400">
     <param name="movie" value="keypress.swf" />
     <param name="quality" value="high" />
     <param name="bgcolor" value="#ffffff" />
     <param name="play" value="true" />
     <param name="loop" value="true" />
     <param name="wmode" value="window" />
     <param name="scale" value="showall" />
     <param name="menu" value="true" />
                    <param name="allowFullScreen" value="true" />
     <param name="devicefont" value="false" />
     <param name="salign" value="" />
     <param name="allowScriptAccess" value="sameDomain" />
    <!--<![endif]-->
     <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>
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
   </object>
  </div>

JnSchAuthor
Participating Frequently
October 19, 2010

I got error before using the html page, when click the swf file itself.

thanks.

October 19, 2010