我在获取ExternalInterface.callBack()时遇到问题;当我像这样动态添加对象和嵌入标签时,在特定情况下工作:
function createBannerObject(swfURL,flashVars, searchParams)
{
/* swfURL -- our template URL
videoURL -- user video URL
backURL -- background picture URL
flashVars -- other user preferences -- string
searchParam -- param for word search -- array */
var flashDiv = document.createElement('div');
flashDiv.id = 'flashvideo';
flashDiv.style.width='1px';
flashDiv.style.height='1px';
// id = myMovie, name = myMovie ------------------------//
flashDiv.innerHTML = '<object id="myMovie" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="100%" align="left"><param name="bgcolor" value="#faa"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+swfURL+'" /><param name="flashvars" value="'+flashVars+'" /><param name="quality" value="high" /><param name="wmode" value="opague" /><embed name="myMovie" src="'+swfURL+'" quality="high" width="100%" height="100%" align="left" allowScriptAccess="always" allowFullScreen="false" bgcolor="#cccccc" wmode="opaque" flashvars="'+flashVars+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
//----------------------------------------------------------
var search = ad_createDomElem('div',false);
search.style.display = 'none';
var searchWord = ad_createDomElem('p',{'id':'keyword'});
searchWord.innerHTML = searchParams[0];
var searchDiv = ad_createDomElem('p',{'id':'search'});
searchDiv.innerHTML = searchParams[1];
var regex1 = ad_createDomElem('p',{'id':'regex1'});
regex1.innerHTML = searchParams[2];
var regex2 = ad_createDomElem('p',{'id':'regex2'});
regex2.innerHTML = searchParams[3];
search.appendChild(searchWord);
search.appendChild(searchDiv);
search.appendChild(regex1);
search.appendChild(regex2);
//-----------------------------------------------------------
flashDiv.appendChild(search);
//-----------------------------------------------------------
document.body.appendChild(flashDiv);
}
现在这里是我的getMovie函数(就像其他人一样)
function getMovie(string)
{
var M$ = navigator.appName.indexOf("Microsoft")!=-1;
if(navigator.userAgent.indexOf('MSIE 9.0')) M$ = false;
return (M$ ? window : document)[string];
}
以下是它无法使用的页面:
http://banners.adfox.ru/110811/adfox/156416/inDynamic.html
这是一个可以使用的页面:不同之处在于不动态添加flash:
http://banners.adfox.ru/110811/adfox/156416/onpage.html
所有JS都可以通过source =)
进行调查现在关于AS3,我使用代码:
Security.allowDomain('*');
ExternalInterface.addCallback("playVideoOnOpen", playVideoOnOpen);
ExternalInterface.addCallback("pauseVideoOnClose", pauseVideoOnClose);
function playVideoOnOpen()
{
}
function pauseVideoOnClose()
{
}
我已成功解决了这个问题:
http://banners.adfox.ru/110811/adfox/156416/dynamicAddEasy.html
再次所有JS里面
问题:动态添加Flash时可能出现什么问题?还是别的什么?
答案 0 :(得分:0)
如果您使用swfobject.js嵌入您的瑞士法郎,那么您的问题就会消失。我一直使用它与外部接口,从来没有你的问题
您也没有将要传递的数据发布到函数中
正如您在下面的代码中看到的那样,它也更加清晰和自我解释。
html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
function loaded() {
var flashvars={}, params={}, attributes={}, tmp, version, width, height, container, flashObj;
flashvars.userId = "1234";
params.menu = "true";
params.quality = "high";
params.allowscriptaccess = "always";
params.allownetworking = "all";
attributes.id = "test";
attributes.name = "test";
attributes.align = "middle";
attributes.allowscriptaccess = "always";
attributes.allownetworking = "all";
tmp = "expressInstall.swf";
version = "10.0.0";
width = "100%";
height = "100%";
container = "replaceMe";// div tag to place the swf in
flashObj = "test.swf?t=" + new Date().getTime(); // anticaching
swfobject.embedSWF(flashObj, container, width, height, version, tmp, flashvars, params, attributes);
}
</script>
</head>
<body onLoad="loaded()" onunload"doUnload( )">
<div id="replaceMe">Loading content.</div>
</body>
</html>
[编辑]
我只是注意到我遗漏了别的东西
不确定我是否曾在IE9中测试过这个问题但是应该适合6-8岁
if (navigator.appName.indexOf("Microsoft") >= 0){
container = document;
}else{
container = window;
}
var result = container[swf].flashCallBackFunction();