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 in开发者_运维知识库cludes 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
The argument passed to ExternalInterface.call
will be eval
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
ExternalInterface.call("window.parent.myFunction");
精彩评论