转自http://www.iamued.com/demo/flashjs/
http://www.iamued.com/qianduan/611.html由RichieLiu 翻译
翻译自:http://www.permadi.com/tutorial/flashjscommand/index.html
今天开发富媒体广告遇到的问题用JS控制flash只在IE平台下有效费尽周折才找到兼容的解决方案。方法如下:
重点在于object的id属性和EMBED的name属性swliveconnect=”true”属性
<objectclassid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase=""id="myFlashMovie" width=481 height=86>
<paramname=movie value="flips2.swf">
<embedplay=false swliveconnect="true" name="myFlashMovie" src="flips2.swf"quality=high bgcolor=#FFFFFF width=481 height=86type="application/x-shockwave-flash" ....>
</embed>
</object >
通过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)