Javascript を使用してフラッシュ関数を呼び出そうとしています。HTMLファイルとswfが同じドメインにあるときは動作していますが、別のドメインにあると動作しなくなります。
これは、SWF を使用してサーバーにあるクロス ドメイン ファイルです。
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" />
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
SWF は、以前に次のようにロードされています。
AC_FL_RunContent("src", "http://www.eyespeakpro.com/OneSentenceLogin.swf",
"width", "100%",
"height", "80%",
"align", "middle",
"id", "OneSentenceLogin",
"quality", "high",
"bgcolor", "#ffffff",
"name", "OneSentenceLogin",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
別のサーバーの HTML ページの一部である場合に失敗する JavaScript コードを次に示します。SWF は OneSentenceLogin と呼ばれ、関数は callChangeSentIn です。
function callExternalInterface(sentIn) {
/* Call a function registered as callChangeSentIn in the SWF named myMovie. */
getMovieName("OneSentenceLogin").callChangeSentIn(sentIn);
// The following error only happens on the other server:
// Uncaught TypeError: Object #<HTMLEmbedElement> has no method 'callChangeSentIn'
}
/* This utility function resolves the string movieName to a Flash object reference based on browser type. */
function getMovieName(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName]
}
else {
return document[movieName]
}
}
別のサーバーから呼び出されたときに、swf がまだロードされているにもかかわらず、メソッド callChangeSentIn が見つからないのはなぜですか?