2009-08-18 4 views
2

現在のプロジェクトでは、SwfObject 2.2を使用してFlashファイルを埋め込み、CRDのGurusはSwfAddress 2.3を使用してSEOのフラッシュを作成しています。SwfAddressとSwfObjectの 'callback'引数との競合

ページに両方のライブラリが含まれている場合、APIでSwfObjectコールバックを使用しようとすると、SwfObjectの読み込みが妨げられることがわかります(http://code.google.com/p/swfobject/wiki/api)。この例では、SwfAddressファイルをHTMLでコメントアウトするだけでこれを切り替えることができます。

申し訳ありません私はこれらの2つのライブラリの絶対URLを以下のコードで指すことができませんでした。

<head> 
    <title>SWFObject 2.2 dynamic embed with callback</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
    <script type="text/javascript" src="swfobject.js"></script> 
    <script type="text/javascript" src="swfaddress.js"></script> 
    <script type="text/javascript"> 
    function outputStatus(e) { 
     alert("e.success = " + e.success +"\ne.id = "+ e.id +"\ne.ref = "+ e.ref); 
    } 
    var params = {}; 
    params.allowscriptaccess = "always"; 

    swfobject.embedSWF("http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test6.swf", "myContent1", "300", "120", "9.0.0", "expressInstall.swf", null, null); 
    swfobject.embedSWF("http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test6.swf", "myContent2", "300", "120", "9.0.0", "expressInstall.swf", null, params, null, outputStatus); 
    </script> 
</head> 

<body> 
    <div id="myContent1"> 
     <h1>Alternative content</h1> 
     <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p> 
    </div> 
    <div id="myContent2"> 
     <h1>Alternative content</h1> 
     <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p> 
    </div> 
</body> 

任意のアイデア?前もって感謝します!

+0

SWFAddress.as externalChangeイベントが発生していない問題が解決されました(swfはまだ埋め込み済みでした) – user531694

答えて

2

これは厳しいものでした。

クイック答え:あなたはのflashVarsのために代わりに「ヌル」の空のオブジェクトを渡す必要がありますと属性:(See my corrected demo code here

swfobject.embedSWF("http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test6.swf", "myContent1", "300", "120", "9.0.0", "expressInstall.swf", {}, {}); 
swfobject.embedSWF("http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test6.swf", "myContent2", "300", "120", "9.0.0", "expressInstall.swf", {}, params, {}, outputStatus); 

全解答:SWFAddressのソースコードに掘り、彼らは書き換えされているSWFObjectの埋め込みを彼らは自分自身を注入することができます。これを行うために必要なことの1つは、渡したすべてのパラメータをそれぞれの関数に転送することです。あなたは、属性オブジェクトのために集めて「nullは」ここにSWFAddressコードでエラーの原因となった。

var _s2e = swfobject.embedSWF; 
    swfobject.embedSWF = function() { 
    _args = arguments; 
    if (typeof _args[8] == UNDEFINED) 
     _args[8] = {}; 
    if (typeof _args[8].id == UNDEFINED) 
     _args[8].id = _args[1]; // <-- ERROR here when this parameter (attributes) is null. 
     _s2e.apply(this, _args); 
     _ref.addId(_args[8].id); 
    } 

エラーが全体の第2の埋め込みが失敗しました。

+0

SwfObjectには空のオブジェクトも必要なので、私はそれを考えていたはずです。 Adobeのドキュメントからコピーしたように、私はそれがうまくいくと考えました。ドー! – mummybot

+0

+1。 2008年以来私は時間を節約し、良い古いstackoverflow。 –

関連する問題