Flash8与javascript集成
利用FLASH页面上层的显示和隐藏来实现(从视觉上)Flash里显示HTML,当然也可以是php,asp,jsp等内容。
首先就是有FLASH的页面的FLASH上面新建层,相关参数可以自己定义。
#Layer1 {
position:absolute;
left:0px;
top:0px;
100px;
height:100px;
z-index:1;
visibility: hidden;
}
该页面调用如下JS代码
Layer_regist.js
//隐藏层
function testLayerHide() {
MM_showHideLayers('Layer1', '', 'hide');
}
//显示层
function show(prodinfo_url) {
url = prodinfo_url;
//FLASH中传过来的参数
myclock = "<iframe src='"+url+"' name='layer1' width='535' height='100%' marginwidth='0' marginheight='0' frameborder='0'></iframe>";
MM_showHideLayers('Layer1', '', 'show');
document.getElementById("Layer1").innerHTML = myclock;
}
function MM_showHideLayers() {
var i, p, v, obj, args = MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i += 3) {
if ((obj=MM_findObj(args[i])) != null) {
v = args[i+2];
if (obj.style) {
obj = obj.style;
v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v;
}
obj.visibility = v;
}
}
}
function MM_findObj(n, d) {
var p, i, x;
if (!d) {
d = document;
}
if ((p=n.indexOf("?"))>0 && parent.frames.length) {
d = parent.frames[n.substring(p+1)].document;
n = n.substring(0, p);
}
if (!(x=d[n]) && d.all) {
x = d.all[n];
}
for (i=0; !x && i<d.forms.length; i++) {
x = d.forms[i][n];
}
for (i=0; !x && d.layers && i<d.layers.length; i++) {
x = MM_findObj(n, d.layers[i].document);
}
if (!x && d.getElementById) {
x = d.getElementById(n);
}
return x;
}
FLASH中调用方法如下:
//隐藏层
getURL("javascript:testLayerHide();");
//显示层
getURL("javascript:show(\'www.maihu.net\')");