请问如何用JS控制下边这个Falsh播放器?比如:开始、暂停、停止等……
<object height="300" align="absmiddle" width="185" id="Hjmp3player_1" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
<param value="always" name="allowScriptAccess">
<param value="http://bulo.hjenglish.com/musicbox/players/List_mp3Player2/mp3player.swf" name="movie">
<param value="high" name="quality">
<param value="noscale" name="scale">
<param value="transparent" name="wmode">
<param value="userid=5109575&listid=11514&autoplay=true&_display=true&_playlist=true&_random=false&hjptype=list&player=3&height=300&width=185" name="FlashVars">
<embed height="300" align="absmiddle" width="185" flashvars="userid=5109575&listid=11514&autoplay=true&_display=true&_playlist=true&_random=false&hjptype=list&player=3&height=300&width=185" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="always" name="Hjmp3player_1" bgcolor="#eeeeee" wmode="transparent" scale="noscale" quality="high" src="http://bulo.hjenglish.com/musicbox/players/List_mp3Player2/mp3player.swf">
</object>
<object height="300" align="absmiddle" width="185" id="Hjmp3player_1" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
<param value="always" name="allowScriptAccess">
<param value="http://bulo.hjenglish.com/musicbox/players/List_mp3Player2/mp3player.swf" name="movie">
<param value="high" name="quality">
<param value="noscale" name="scale">
<param value="transparent" name="wmode">
<param value="userid=5109575&listid=11514&autoplay=true&_display=true&_playlist=true&_random=false&hjptype=list&player=3&height=300&width=185" name="FlashVars">
<embed height="300" align="absmiddle" width="185" flashvars="userid=5109575&listid=11514&autoplay=true&_display=true&_playlist=true&_random=false&hjptype=list&player=3&height=300&width=185" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="always" name="Hjmp3player_1" bgcolor="#eeeeee" wmode="transparent" scale="noscale" quality="high" src="http://bulo.hjenglish.com/musicbox/players/List_mp3Player2/mp3player.swf">
</object>
function getFlashMovieObject(movieName)
{
if (window.document[movieName])
{
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1)
{
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
}
else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
{
return document.getElementById(movieName);
}
}
Example: <a href="#" onclick="getFlashMovieObject('flashId').Play();">Play</a>播放动画:Play()
停止动画:StopPlay()
动画是否正在播放:IsPlaying()
跳转到某帧:GotoFrame(frame_number)
获取动画总帧数:TotalFrames()
回传当前动画所在帧数:CurrentFrame()
使动画返回第一帧:Rewind()
放大指定区域:SetZoomRect(left,top,right,buttom)
改变动画大小:Zoom(percent)
使动画在 x,y 方向上平移:Pan(x_position,y_position,unit)
返回动画被载入的百分比:PercentLoaded()
加载动画:LoadMovie(level_number,path)
movie_clip 跳转到指定帧数:TGotoFrame(movie_clip,frame_number)
movie_clip 跳转到指定标签:TGotoLabel(movie_clip,label_name)
回传 movie_clip 当前帧:TCurrentFrame(movie_clip)
回传 movie_clip 当前标签:TCurrentLabel(movie_clip)
播放 movie_clip:TPlay(movie_clip)
停止 movie_clip 的播放:TStopPlay(movie_clip)
获取变量:GetVariable(variable_name)
变量赋值:SetVariable(variable_name,value)
call 指定帧上的 action:TCallFrame(movie_clip,frame_number)
call 指定标签上的 action:TCallLabel(movie_clip,label)
获取 movie_clip 的指定属性:TGetProperty(movie_clip,property)
设置 movie_clip 的指定属性:TSetProperty(movie_clip,property,number)
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Example4</title>
<script type="text/javascript">
function getFlashMovieObject(movieName) {
if (window.document.movieName) return window.document.movieName;
if (navigator.appName.indexOf("Microsoft Internet") == -1) {
if (document.embeds && document.embeds.movieName) return document.embeds.movieName;
} else {
return document.getElementById(movieName);
}
}</script>
</head>
<body>
<object height="300" align="absmiddle" width="185" id="Hjmp3player_1" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
<param value="always" name="allowScriptAccess">
<param value="http://bulo.hjenglish.com/musicbox/players/List_mp3Player2/mp3player.swf" name="movie">
<param value="high" name="quality">
<param value="noscale" name="scale">
<param value="transparent" name="wmode">
<param value="userid=5109575&listid=11514&autoplay=true&_display=true&_playlist=true&_random=false&hjptype=list&player=3&height=300&width=185" name="FlashVars">
<embed height="300" align="absmiddle" width="185" flashvars="userid=5109575&listid=11514&autoplay=true&_display=true&_playlist=true&_random=false&hjptype=list&player=3&height=300&width=185" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="always" name="Hjmp3player_1" bgcolor="#eeeeee" wmode="transparent" scale="noscale" quality="high" src="http://bulo.hjenglish.com/musicbox/players/List_mp3Player2/mp3player.swf">
</object>
<button onclick="getFlashMovieObject('Hjmp3player_1').StopPlay()">测试</button>
</body>
</html>
谁来帮我看看,谢谢
2.基本上你的代码已经对了,只是javascript不能跨域,同样也不能控制跨域的flash,要将flash放到同一个域中
3.我在我的Blog里加了Example,如果有问题请查看http://www.51tasty.com/example1/example1.html,或留言
function F(w, h) {
this.width = w;
this.height = h;
}
function FS(x, y, w, h) {
F.call(this, w, h);
this.x = x;
this.y = y;
}
FS.prototype = new F()
FS.prototype.constructor = FS;
delete FS.prototype.width;
delete FS.prototype.height;
var r = new FS(1, 2, 3, 4);
alert(r.x);
alert(r["y"]);
alert(r["width"]);
alert(r.height);
如果你愿意用eval("window.document."+movieName),我当然没有意见......