简体   繁体   English

如何在 iFrame 中使用 Flash AS2 swf 中的 ExternalInterface 来调用 javascript 方法?

[英]HOw can I use ExternalInterface from my Flash AS2 swf in an iFrame to call a javascript method?

I have a PHP script which includes a header file (header.php) which includes a javascript file containing some javascript methods.我有一个 PHP 脚本,其中包括一个 header 文件(header.php),其中包括一个 javascript 文件,其中包含一些 ZDE9B9ED708D7E2E19ZEEFF 方法。

ie - IE -

Main.php => Main.php =>

include("header.php");
// This page also embeds a swf in an iFrame (myFlash.swf)

header.php => header.php =>

<html>
<head>
<script type="text/javascript" src="javascript_methods.js"></script>
</head>
<body>

javascript_methods.js => javascript_methods.js =>

myFunction() {
alert("function called");
}

myFlash.swf => 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.我在我的应用程序的其他地方使用了 ExternalInterface 并且(认为)我也是这样做的,但唯一的区别是这次 swf 在 iFrame 内,所以认为这可能会导致问题。 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.是否有解决方案可以通过 iFrame 从 Flash 与 javascript 进行通信,或者这不是问题,我在其他地方有问题。

thanks谢谢

The argument passed to ExternalInterface.call will be eval ed in the document where the flash is placed.传递给ExternalInterface.call的参数将在放置eval的文档中进行评估。 This means that for this flash to reach the parent windows code, then it needs to do这意味着对于这个 flash 到达父 windows 代码,那么它需要做

ExternalInterface.call("window.parent.myFunction");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法从QWebView中的Javascript调用Flash(Swf)方法 - Can't call Flash (Swf) method from Javascript within QWebView 如何通过Flex的ExternalInterface调用iframe的父html页面的函数(具有要从其中调用函数的swf)? - How to call function of parent html page of an iframe(having swf from which to call function) by ExternalInterface from Flex? 如何使用externalInterface允许Flash调用javascript更新屏幕上的值? - How do I use externalInterface to allow Flash to call javascript to update a value on the screen? 从Flash调用ExternalInterface来实现OOP javascript中的功能 - ExternalInterface call from flash to function in OOP javascript 从Flash到Javascript OOP对象的ExternalInterface调用 - ExternalInterface call from flash to Javascript OOP object swf文件可以使用`ExternalInterface.call()`函数为javascript进行初始化吗? - can swf file initialize itself for javascript with `ExternalInterface.call()` function? 使用Javascript来调用Flash(.swf)文件中的方法吗? - Use Javascript to call method within a flash (.swf) file? 在iframe中从SWF调用Javascript - Javascript call from swf in iframe 我可以通过Javascript在flash(AS2)中设置变量 - Can I set variable in flash (AS2) by Javascript 如何在Flash的ExternalInterface和JavaScript之间传递信息? - How do I pass information between Flash's ExternalInterface and JavaScript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM