今天开发富媒体广告遇到的问题用JS控制flash只在IE平台下有效费尽周折才找到兼容的解决方案。方法如下:
重点在于object的id属性和EMBED的name属性swliveconnect=”true”属性
codebase=""id="myFlashMovie" width=481 height=86>
通过js获取flash对象的方法兼容表如下
通过上图得到JavaScript方法来获取flash对象 兼容多浏览器
functiongetFlashMovieObject(movieName){
if (window.document[movieName]){
return window.document[movieName];
}
if (navigator.appName.indexOf("MicrosoftInternet")==-1){
if (document.embeds &&document.embeds[movieName])
return document.embeds[movieName];
}else// if(navigator.appName.indexOf("Microsoft Internet")!=-1)
{
return document.getElementById(movieName);
}
}
获取到flash对象可以利用相关方法进行操作
播放Play()
停止StopPlay()
停止并回到首帧Rewind()
下一帧TGetProperty(nameOfTargetMovieClip,propertyIndex) and GotoFrame(frameNum)
方大或缩小Zoom(relative percentage)
发送数据SetVariable(variableName,variableValue)
读取数据GetVariable(variableName)