Reputation:
import flash.external.ExternalInterface;
//ExternalInterface.call("alert", "what");
ExternalInterface.call("show_alert");
HTML CODE
<script type="text/javascript">
function show_alert() {
alert('no');
}
</script>
<div id="flashContent">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="test" align="middle">
<param name="movie" value="test.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#999900" />
<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="allowScriptAccess" value="sameDomain" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="test.swf" width="550" height="400">
<param name="movie" value="test.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#999900" />
<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="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>
Upvotes: 0
Views: 4968
Reputation: 19
If you are creating a file using AS2 then try this : _root.getURL("javascript:show_alert();"); instead of ExternalInterface.call("show_alert");
If you are using the AS3 then the code is perfect, no need to change.
Due to some security features Flash Player can not communicate with the javascript locally. If you run the same files on the live server or localhost, it will work.
Upvotes: 1