如何在 iFrame 中使用 Flash AS2 swf 中的ExternalInterface 来调用javascript 方法?
我有一个 PHP 脚本,其中包含一个头文件 (header.php),其中包含一个包含一些 javascript 方法的 javascript 文件。
即
-Main.php =>
include("header.php");
// This page also embeds a swf in an iFrame (myFlash.swf)
header.php =>;
<html>
<head>
<script type="text/javascript" src="javascript_methods.js"></script>
</head>
<body>
javascript_methods.js =>;
myFunction() {
alert("function called");
}
myFlash.swf =>
import flash.external.ExternalInterface;
//When I want to call the javascript function myFunction() -
ExternalInterface.call("myFunction");
我在我的应用程序中的其他地方使用了ExternalInterface,并且(认为)我以相同的方式进行了操作,但唯一的区别是这次swf位于iFrame内,因此认为这可能会导致问题。有没有解决方案可以通过 iFrame 从 Flash 与 javascript 进行通信,或者这不是问题,而我在其他地方遇到问题。
谢谢
I have a PHP script which includes a header file (header.php) which includes a javascript file containing some javascript methods.
ie -
Main.php =>
include("header.php");
// This page also embeds a swf in an iFrame (myFlash.swf)
header.php =>
<html>
<head>
<script type="text/javascript" src="javascript_methods.js"></script>
</head>
<body>
javascript_methods.js =>
myFunction() {
alert("function called");
}
myFlash.swf =>
import flash.external.ExternalInterface;
//When I want to call the javascript function myFunction() -
ExternalInterface.call("myFunction");
I have used ExternalInterface elesewhere in my app and (think) i did it the same way but the only difference is this time the swf is inside an iFrame so think this might be causing the problem. Is there a solution to making this communication to javascript from Flash through an iFrame, or is this not the issue and I have a problem somewhere else.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
传递给
ExternalInterface.call
的参数将在放置 Flash 的文档中进行评估
。这意味着要使此闪存到达父窗口代码,它需要执行以下操作The argument passed to
ExternalInterface.call
will beeval
ed in the document where the flash is placed. This means that for this flash to reach the parent windows code, then it needs to do