当javascript函数调用时,Flash文件无法正常工作

时间:2013-06-12 11:01:06

标签: javascript html flash

我是flash的新手

这里使用的是javascript函数来观看Flash视频

flash文件名是a0.swf,a1.swf ...

这是我的javascript函数

<script>
var count=0;
function mafunct(newSrc){
    alert("hi");
var path="a"+count+".swf";  

 flash+='<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" WIDTH="100%" HEIGHT="100%">';          
    flash+='<PARAM NAME=movie VALUE="'+path+'">';          
    flash+='<PARAM NAME="PLAY" VALUE="false">';  
    flash+='<PARAM NAME="LOOP" VALUE="false">';
    flash+='<PARAM NAME="QUALITY" VALUE="high">';
    flash+='<PARAM NAME="SCALE" VALUE="SHOWALL">';
    flash+='<EMBED NAME="testmovie" SRC="Menu.swf" WIDTH="100%" HEIGHT="100%"PLAY="false" LOOP="false" QUALITY="high" SCALE="SHOWALL"swLiveConnect="true"PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">';
    flash+='</EMBED>';
    flash+='</OBJECT>';     

count++;
alert(path+"aa");
}
</script>

<button onclick="mafunct()">next</button>

当此按钮单击时,将不会发生任何事情

编码有问题吗?

如果您之前发生过相同的isuue并解决它,或者您知道答案,请在下面提及

关于..Prasanth AR

更新我的问题在这里..

<script>
var count=0;
function mafunct(flash){
var path="a"+count+".swf";  

    flash+='<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" WIDTH="100%" HEIGHT="100%">';          
    alert(path);
    flash+='<PARAM NAME=movie VALUE='+path+' >';          
    flash+='<PARAM NAME="PLAY" VALUE="false">';  
    flash+='<PARAM NAME="LOOP" VALUE="false">';
    flash+='<PARAM NAME="QUALITY" VALUE="high">';
    flash+='<PARAM NAME="SCALE" VALUE="SHOWALL">';
    flash+='<EMBED NAME="testmovie" SRC="Menu.swf" WIDTH="100%" HEIGHT="100%"PLAY="false" LOOP="false" QUALITY="high" SCALE="SHOWALL"swLiveConnect="true"PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">';
    flash+='</EMBED>';
    flash+='</OBJECT>';     
    alert(flash);
count++;

}
</script>

<button onclick="mafunct()">next</button>

此处警报正常,但闪存ID未被查看...

1 个答案:

答案 0 :(得分:3)

使用我在question中找到的内容,我认为这应该会有所帮助。

var path = var path = document.location.href;
path = path.substr(0, path.lastIndexOf('/') + 1);
var count = 0;
function isIE() {
    return navigator.userAgent.lastIndexOf('Trident') > 0;
}

function mafunct(newSrc) {
    var version = '6,0,29,0';

    var name = document.createElement('param');
    name.setAttribute('name', 'movie');
    name.setAttribute('value', path + 'a' + count + '.swf');

    if (!isIE()) {
        var inner = document.createElement('object');
        inner.setAttribute('type', 'application/x-shockwave-flash');
        inner.setAttribute('data', path + 'a' + count + '.swf');
        inner.setAttribute('width', '100%');
        inner.setAttribute('height', '100%');
    }

    var flash = document.createElement('object');
    flash.setAttribute('id', 'flashMovie');
    flash.setAttribute('classid', 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000');
    flash.setAttribute('width', '100%');
    flash.setAttribute('height', '100%');
    flash.appendChild(name);
    if (!isIE()) {
        flash.appendChild(inner);
    }

    if (document.getElementById('flashMovie')) {
        var movieObject = document.getElementById('flashMovie');
        movieObject.parentNode.replaceChild(flash, movieObject);
    } else {
        var div = document.createElement('div');
        div.setAttribute('id', 'multimedia');
        div.appendChild(flash);
        document.appendChild(div);
    }
    count++;
 }

编辑:将代码更改为始终添加新的Flash对象以替换现有的Flash对象。